Algorithms and Data Structures · Junior · Question 50 of 75

What is the time to find a value in a balanced BST with n nodes?

Explanation

Each step goes down one level, and a balanced tree has about log₂ n levels. If the tree degenerates into a chain (for example, after inserting sorted values), search becomes O(n).

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 50

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz