Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > University Math Help > Other Advanced Topics
Reply
 
Thread Tools Display Modes
  #1  
Old October 16th, 2009, 12:18 AM
Newbie
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Acessd23 is on a distinguished road
Default Big oh problem #2

What is the big o of this code.


K=1;
do
j=1;
do
..
..

..
j=2*j;
while(j<=n);
k=k+1;
while (K<=n);

Last edited by mr fantastic; October 16th, 2009 at 04:47 AM.
Reply With Quote
Advertisement
 
  #2  
Old October 16th, 2009, 12:25 AM
CaptainBlack's Avatar
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,379
Country:
Thanks: 667
Thanked 3,619 Times in 2,916 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

Quote:
Originally Posted by Acessd23 View Post
What is the big o of this code.


K=1;
do
j=1;
do
..
..

..
j=2*j;
while(j<=n);
k=k+1;
while (K<=n);
The trip count for the inner loop is floor(log_2(n)+1)=O(log(n)), now the outer loop trip count is: .. ?

CB
__________________
Truth does not change because it is, or is not, believed by a majority of the people.

Giordano Bruno
Reply With Quote
  #3  
Old October 16th, 2009, 12:28 AM
Newbie
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Acessd23 is on a distinguished road
Default

the outer loop is N so

the answer is o(n*log(n)) ???
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 11:57 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.