BST Search/Insert: Running Time
What is the running time of TreeSearch() or TreeInsert()?
A: O(h), where h = height of tree
What is the height of a binary search tree?
A: worst case: h = O(n) when tree is just a linear string of left or right children
- We’ll keep all analysis in terms of h for now
- Later we’ll see how to maintain h = O(lg n)