Results 1 to 7 of 7
Thread: time complexity questions
 07122010, 09:53 PM #1Member
 Join Date
 May 2010
 Posts
 44
 Rep Power
 0
time complexity questions
what are the time complexities in these two cases, big O notation.
1.Java Code:int a =3; while (a <= n) a = a*a;
2.Java Code:public void foo (int n, int m) { int i = m; while (i > 100) i = i/3; for (int k=i ; k>=0; k) { for (int j=1; j<n; j*=2) System.out.print(k + "\t" + j); System.out.println(); } }
and the second one i'm just confused. although the general rule is that with two loops is O(n^2), but i'm assuming they're tricking us here...
 07122010, 10:09 PM #2
Is this a java programming question?
 07122010, 10:21 PM #3Member
 Join Date
 May 2010
 Posts
 44
 Rep Power
 0
I dunno. It's part of my Intro to Computer Sciences  Java course...
 07132010, 06:11 AM #4Member
 Join Date
 May 2010
 Posts
 44
 Rep Power
 0
Does anyone have an idea??
 07132010, 07:17 AM #5Java Code:
int a =3; while (a <= n) a = a*a;
Java Code:public void foo (int n, int m) { int i = m; while (i > 100) i = i/3; for (int k=i ; k>=0; k) { for (int j=1; j<n; j*=2) System.out.print(k + "\t" + j); System.out.println(); } }
 07132010, 08:15 AM #6
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,292
 Blog Entries
 7
 Rep Power
 24
 07132010, 11:02 AM #7
Similar Threads

Time complexity  foor loop
By hawaiifiver in forum New To JavaReplies: 5Last Post: 02052011, 05:06 PM 
Time Complexity Java Code?
By Lyricid in forum New To JavaReplies: 11Last Post: 12082009, 05:27 PM 
complexity issue!!
By deepa8400 in forum New To JavaReplies: 4Last Post: 08252009, 04:25 AM 
Please tell me I am not crazy... Time Complexity (BigO) Question
By Jordan in forum New To JavaReplies: 2Last Post: 11042008, 03:48 AM 
Singleton considered stupid, Java and complexity
By fishtoprecords in forum Forum LobbyReplies: 11Last Post: 07062008, 03:38 AM
Bookmarks