time complexity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miller72
    New Member
    • Feb 2019
    • 1

    time complexity

    Hi everyone!

    I've been recently asked by one of my friends to help him out with these two following questions.

    1.Find the time complexity of this two piece of code and write which one is bigger?

    for( int i=2 ; i<= n; i=i*i )
    for( int j=2 ; j <= i; j=j*j )
    print(j);


    while ( n>1 ){
    print(n);
    n=n/2;
    }



    2.An algorithm that takes the roots of two same Binary Search Trees. if the roots are same return TRUE and if not return FALSE.
    (corresponding nodes have the same values.)
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Variable n is not properly declared in the code you gave, therefore you will probably get no answer, of just incorrect answers.

    Comment

    Working...