Time complexity, Binary Search Trees

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

Your friend should stop getting you to do his homework for him.

4 Likes

@ahmadobur77: it looks as if your idea of helping your friend is simply to ask someone else to do it. That’s not how things work around here. smile

I suggest you tell your friend to sign up to the forums himself, and ask his own questions, explaining exactly where he needs help. Other members will be happy to offer guidance and advice, but not to produce finished answers.

(Your friend also needs to decide if he wants help with Java or JavaScript, as they are not the same.)

3 Likes

< minorly off-topic >
The expression I’ve always loved is: “As you are entering (in/exiting/whatever) college, perhaps an Aristotelian analogy is in order: Java is to Javascript as Pen is to Penguin.”

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.