Except where noted, these are to be turned in as hard copy. You can write solutions out by hand, or write them on your computer and print them.
Papers must not have ragged, spiral-notebook edges. Multiple page solutions must be stapled. Solutions not following these guidelines will be returned ungraded. I regret this rigidity, but it is necessary given the number of students in CSSE 230 this term.
Late days may not be used for written assignments.
printPreorder
method in Figure 18.22 (Weiss, p. 612) is O(N). You may assume that the tree is perfect (i.e., full, balanced, and size 2k
- 1 for some integer
k).
(15 points) In class we drew a diagram of the sort decision tree for selection sort on three elements. For this problem, you’ll do the same thing for insertion sort on 4 elements.
Because the tree is so large, just show the root, its left child, and the left subtree of the left child. For consistency, when comparing ai and aj where i < j, always write ai : aj (instead of aj : ai) so that going left in the tree will always be the no-additional-movement-of-data direction for insertion sort. Thus (for example) a1 < a2 < a3 < a4 should be the label on the leftmost leaf of the tree.
The resulting tree is quite wide. You will probably want to work sideways on the page.
These problems are for you to think about and convince yourself that you could do them. It would be good practice to actually do them, but you are not required to turn them in.