The tim The time to search for a value in a tree hinges on the depth of the tree
ID: 3544970 • Letter: T
Question
The tim
Explanation / Answer
Worst case analysis :
tree is balanced and has x elements:
add takes O(log x) as depth becomes logx;
So, n adds and n removes takes n*O(log x) + n* O(log x)
=2nO(log x);
=O(log x); (similar according to Big _O notation)
Tree is imbalanced
add takes O( x) as depth becomes x in worst case;
So, n adds and n removes takes n*O(x) + n* O(l x)
=2nO(x);
=O(x); (similar according to Big _O notation)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.