Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,723 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,314 people online right now. Registration is fast and FREE... Join Now!




Big theta notation

 
Reply to this topicStart new topic

Big theta notation

efus
post 4 Oct, 2008 - 01:29 PM
Post #1


New D.I.C Head

*
Joined: 4 Oct, 2008
Posts: 2

Hi,
I need to make a big-theta notation on an algoritm I made. The algoritm is soposed to find factors of a number. This is the algoritm implemented in java:
CODE

public class factor {

    public static void main (String argv[])
    {    
        int number =(Integer.parseInt(argv[0]));
        int counter = 0;

        for(counter = 1; counter <= number/2; counter++)
        {
            if(number % counter == 0)System.out.println(counter);
        }
        System.out.println(number);
    }
}

I figured the theta notation to this is: O(N)

The problem is now that i need to express big theta as a function of of the length of N (the number
of bits in N). I have no idea what I am supposed to do here? I would greatly appreciate if anyone could help.
User is offlineProfile CardPM

Go to the top of the page

William_Wilson
post 4 Oct, 2008 - 01:53 PM
Post #2


lost in compilation

Group Icon
Joined: 23 Dec, 2005
Posts: 3,951



Thanked 13 times

Dream Kudos: 3275

Expert In: Java, C, Javascript

My Contributions


I'm not really sure what you are trying to do either, perhaps a longer explanation?

An int in Java would have 4 bytes --> 32 bits if that helps.
User is offlineProfile CardPM

Go to the top of the page

efus
post 4 Oct, 2008 - 02:15 PM
Post #3


New D.I.C Head

*
Joined: 4 Oct, 2008
Posts: 2

I am supposed to make an algoritm that finds the factors of a number.
So I made an algoritm that checks if modulus of that number and any number up to and including the number/2. I then need to make big theta notation to express how long
my algorithm takes.
Since the number of calculations is directly proportional to how high the input number is, the big theta notation must be O(N).
Then I need to express this as a function of the length of N (the number
of bits in N).
This is the part where I am lost. Like you say an int in fx java is 32bits so no matter what value N has, it will always be 32 bits?
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 10:09AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month