Author: Josh Hug

## Example Implementations

BST (also supports ordered operations)

## Recommended Problems

### C level

- What is the best case BST height in terms of N? Worst case?
- If shuffling yields $\log N$ tree height (with extremely high probability), why don't we simply shuffle our input data before building our BST based symbol table to avoid worst case behavior?
- [Adapted from Textbook 3.2.3] Give two orderings of the keys
`A X C S E R H`

that, when inserted into an empty BST, yield the best case height. Draw the tree. - Delete the root from the tree you created for question C-3.

### B level

[Adapted from Textbook 3.2.4] Suppose that a certain BST has keys that are integers between 1 and 10, and we search for 5. Which sequence(s) of keys below are possible during the search for 5?

`a. 10, 9, 8, 7, 6, 5 b. 4, 10, 8, 7, 53 c. 1, 10, 2, 9, 3, 8, 4, 7, 6, 5 d. 2, 7, 3, 8, 4, 5 e. 1, 2, 10, 4, 8, 5`

- Give an example of something that you might like to store as a key in a symbol table for which there is no natural compare method.
- Do there exist any objects for which it is impossible to define a total order? In other words, can we always write a compare method if we're willing to do the work, or are some data types fundamentally impossible to compare other than for equality?
- When we delete from a BST, we always chose either the predecessor or successor as a replacement for the root. We said that these two items always have zero or one children. Why?
- Is the delete operation commutative? In other words, if we delete x, then y, do we always get the same tree as if we delete y, then x?
- Problem 1 from the Fall 2014 midterm.

### A+ level

- Problem 3 from the Fall 2009 midterm. This problem is magnificent in its elegance and difficulty.