Height after sorted inserts
Warm-up · Trace the algorithm · about 5 min
The keys 1, 2, 3, 4, 5, 6 are inserted in this order into an empty BST. No rebalancing happens.
Answer each question before the step plays.
Example 1
Input:
[[1,2,3,4,5,6]]
Output:
6
The final tree is a chain of 6 nodes.
Constraints
- Height counts the nodes on the longest root-to-leaf path
- An empty tree has height 0
Learn the idea first: Why balance matters, a visual lesson.
More Why balance matters problems
- Cost of search in a chain Warm-up
- Choose an insertion order for balance Standard
- Height of a tree Standard
- Is the tree height-balanced? Standard
- Build a balanced BST from a sorted array Challenge