FrontendX
Prove randomly built BST has O(log n) expected height
hard
Description
AI Assistance
Solution
Test Cases
Test Result
Submissions
Canvas
Prove randomly built BST has
O(log n) expected height
Analyze the prove randomly built bst has o(log n) expected height.
Examples
Example 1
Input:
"test_input_1"
Output:
"output_1"
Example 2
Input:
"test_input_2"
Output:
"output_2"
Hints
Hint 1
Recall that a BST's height is determined by the longest path from root to leaf, and in a perfectly balanced BST, this is log₂(n).
Hint 2
Consider how randomization affects the insertion order: what's the probability that a new node becomes the new root, subtly balancing the tree?
Hint 3
Analyze the expected value of the height by modeling the tree's growth as a random process, using linearity of expectation to bound the total height.
Prove randomly built BST has O(log n) expected height
Analyze the prove randomly built bst has o(log n) expected height.