| BinarySearch(0,14) | Middle: 7 | blueberry < gooseberry |
| BinarySearch(0,6) | Middle: 3 | blueberry < boysenberry |
| BinarySearch(0,2) | Middle: 1 | blueberry > blackberry |
| BinarySearch(2,2) | Middle: 2 | blueberry = blueberry |
| BinarySearch(0,14) | Middle: 7 | carrot < gooseberry |
| BinarySearch(0,6) | Middle: 3 | carrot > boysenberry |
| BinarySearch(4,6) | Middle: 5 | carrot < currant |
| BinarySearch(4,4) | Middle: 4 | carrot < cranberry |
| BinarySearch(4,3) |
| BinarySearch(0,14) | Middle: 7 | currant < gooseberry |
| BinarySearch(0,6) | Middle: 3 | currant > boysenberry |
| BinarySearch(4,6) | Middle: 5 | currant = currant |
| BinarySearch(0,14) | Middle: 7 | kiwi > gooseberry |
| BinarySearch(8,14) | Middle: 11 | kiwi < mulberry |
| BinarySearch(8,10) | Middle: 9 | kiwi > huckleberry |
| BinarySearch(10,10) | Middle: 10 | kiwi < loganberry |
| BinarySearch(10,11) |
| Memory Contents (in decimal) |
Cell | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | R | 0 | W | 5 | E | 1 | S | 3 | A | 11 | N | 7 |
Sequence: R -> W -> Y -> T -> P -> Q
Note: There are two possible correct answers to the next two parts, depending on which pair of empty cells are used for the newly inserted item. (cells [5,6] or [13,14] were available).
| Memory Contents (in decimal) |
Cell | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | Q | 0 | W | 11 | G | 15 | R | 3 | T | 5 | Y | 9 | U | 13 | P | 1 |
or
| Memory Contents (in decimal) |
Cell | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | Q | 0 | W | 11 | E | 12 | R | 3 | T | 13 | Y | 9 | G | 15 | P | 1 |
Again, depending on last part, answer should be
| Memory Contents (in decimal) |
Cell | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | Q | 0 | W | 11 | G | 15 | R | 11 | T | 5 | Y | 9 | U | 13 | P | 1 |
or
| Memory Contents (in decimal) |
Cell | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | Q | 0 | W | 11 | E | 12 | R | 11 | T | 13 | Y | 9 | G | 15 | P | 1 |
I made a mistake in stating the original assignment (since corrected), as I errantly said to use the tree from "Figure 9.19 on page 320". This is a tree in Figure 9.19 on page 310 and there is a larger tree on page 320. Given the confusion, I'll accept answers based on either model.
For the tree on page 310,
"michael" would become the right child of "mari"
"kim" would become the right child of "kate"
"jill" would become the left child of "jim"
"louis" would become the left child of "mari"
For the tree on page 320,
"michael" would become the left child of "nell"
"kim" would become the left child of "kit"
"jill" would become the right child of "christopher"
"louis" would become the left child of "mari"
1, 2, 4, 7, 3, 5, 8, 9, 6, 10
7, 4, 2, 1, 8, 5, 9, 3, 6, 10