BST from Sorted Array
Take the middle as the root and recurse on both halves, for a tree of height log n.
Build and Validate a BST: Seven sorted values, balanced
Indices 0 to 6: the middle is index 3, 4. It is the root. Everything before it goes left, everything after goes right.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(log n)
Before this
Taught by the same lesson
Build and Validate a BST covers these too, in the same run.