Exercise 7 Name __________________
Score __/ 14
Document last modified:
- (2) For the set of keys {1, 4, 5, 10, 16, 17, 21} draw the binary search
trees of height 2 and 3.
- (4) Exercise 12.1-3 The part using a stack. Hint: Use a boolean variable
to track whether the left subtree has been traversed.
- (4) Give recursive algorithms that perform preorder and postorder tree
walks in Q(n) time on a tree of n nodes.
- (2) Exercise 12.2-1
Suppose that we have the numbers between 1 and
1000 in a binary search tree and want to search for the number 363. Which of
the following sequences could not be the sequence of nodes examined?
Mark the first number in error.
- 2, 252, 401, 398, 330, 344, 397, 363
- 924, 220, 911, 244, 898, 258, 362, 363
- 925, 202, 911, 240, 912, 245, 363
- 2, 399, 387, 219, 266, 382, 381, 278, 363
- 935, 278, 347, 621, 299, 392, 358, 363
- (2) Exercise 12.3-1