Background: Ch. 13.1, 13.2, 13.3.
Due October 10th:
- 5.1: CLR Exercise 13.2-1 (pg. 249).
- 5.2: Show how to create a complete binary search tree. Prove
it is complete (i.e., deepest level is ``left justified''.) [Extra
credit!]
- 5.3: Show the binary tree resulting from inserting the letters of
the word ``algorithm'' into a binary tree. What is the depth of the
tree?
- 5.4: Consider the following sorting algorithm. Given a list of
n elements, choose one uniformly at random. Make it the root of a
binary search tree. Now create two sublists corresponding to numbers
that will go to the left of the root and numbers that will go to the
right of the root. Recursively create binary search trees for each of
these lists, then attach them to the root. Finally, run SORT-TREE to output the elements in order. Ok, so what's the
expected running time of this sorting algorithm? (Hint: The analysis
here is trivial once you recognize what the algorithm is doing.)
- 5.5: Given a binary search tree T specified in terms of four
arrays,
,
,
, and
, give pseudocode for
performing a rotation at node i.
Up: HOMEWORK
Previous: Homework 4