Results 1 to 3 of 3

Math Help - Big oh problem #2

  1. #1
    Newbie
    Joined
    Oct 2009
    Posts
    3

    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 02:47 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Oct 2009
    Posts
    3
    the outer loop is N so

    the answer is o(n*log(n)) ???
    Follow Math Help Forum on Facebook and Google+

Search Tags


/mathhelpforum @mathhelpforum