Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (s3a):

[Efficient algorithm to traverse tree in time O(k+1) question] http://f.imgtmp.com/BMas4.jpg How do I make an algorithm that's efficient like it asks? Also isn't the +1 irrelevant for the big O notation or am I missing something?

OpenStudy (s3a):

Like, could the notation be simplied to O(n)?

OpenStudy (rsmith6559):

void printAtMost( key x, treeNode n ) { if( n < x ) { print n if( n->left ) printAtMost( x, n->left ); if( n->right ) printAtMost( x, n->right ); } return; }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!