This preview shows page 1. Sign up to view the full content.
CMPS 101
Final Review Problems
1.
Let
T
be a binary tree, and let
)
(
T
n
and
)
(
T
h
denote its number of nodes and height, respectively.
Show
that
))
(
lg(
)
(
T
n
T
h
≥
.
(Hint: this was proved in the solutions to hw6.)
2.
Trace HeapSort on the following arrays
a.
(9, 3, 5, 4, 8, 2, 5, 10, 12, 2, 7, 4)
b.
(5, 3, 7, 1, 10, 12, 19, 24, 5, 7, 2, 6)
c.
(9, 8, 7, 6, 5, 4, 3, 2, 1)
3.
Draw the Binary Search Tree resulting from inserting the keys: 5
8
3
4
6
1
9
2
7 (in that order) into
an initially empty tree.
Write pseudocode for the following recursive algorithms, and write their output
when run on this tree.
a.
InOrderTreeWalk()
b.
PreOrderTreeWalk()
c.
PostOrderTreeWalk()
Note: Some of the topics represented by the following problems my not be covered by end of business
Tuesday 8/11/09.
If that is the case, those topics will not appear on the final exam.
4.
The predecessor of a node
x
in a Binary Search Tree is defined to be the node which is printed
immediately before
x
in an InOrderTreeWalk().
Let
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 12/03/2009 for the course CS CS101 taught by Professor Agoreback during the Spring '09 term at American College of Gastroenterology.
 Spring '09
 AgoreBack
 Sort

Click to edit the document details