2 Replies - 6112 Views - Last Post: 04 October 2008 - 03:15 PM

#1 efus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 04-October 08

Big theta notation

Post icon  Posted 04 October 2008 - 02:29 PM

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:
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.

Is This A Good Question/Topic? 0
  • +

Replies To: Big theta notation

#2 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Big theta notation

Posted 04 October 2008 - 02:53 PM

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.
Was This Post Helpful? 0
  • +
  • -

#3 efus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 04-October 08

Re: Big theta notation

Posted 04 October 2008 - 03:15 PM

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?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1