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.)
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.)
Comment