Review for the Final Exam
1 Suppose that we have numbers between 1 and 1000 in a
binarysearchtree BST and we wantto search for the
number 363 Which of the followingsequences could not be
the sequence of nodes examined
925 202 911 240 912 245 363
924 220 911 244 898 258 362 363
rootg2 9240root
204
244
240
980
120
2450
13630 36203g
Not a valid sequence Yes this is a valid sequence
2 Consider the binary search tree BST below where each
node has a label Note that the label is notthekey Assume
that all the keys are distinct
Which are the nodes with minimum andmaximum keysrespectively
What is the heightof the node N3
What is the depth of the node N5
Find the successor of the nodes N9 N3 and N10
Find the predecessor ofthe nodes N9 and N5
, List the nodes using the inordertree walk
List the leaf nodes
Write the resulting BST afterdeleting the node N3
N1
N2 143
NH N5 NG N7
9 NIO NII
N8
112
minimum key N4
maximum key NII
height of the node N3 is 3
depth of the node N5 is 2
successor of N9 is N6
110 nia
N5 is N1
predecessor of
Y is this
In order tree walk
Ny N2 NS NS N1 N19 NG N 3 Nio N12 N7 N1
Leaf nodes
414 No N9 N 2 NY
1 Suppose that we have numbers between 1 and 1000 in a
binarysearchtree BST and we wantto search for the
number 363 Which of the followingsequences could not be
the sequence of nodes examined
925 202 911 240 912 245 363
924 220 911 244 898 258 362 363
rootg2 9240root
204
244
240
980
120
2450
13630 36203g
Not a valid sequence Yes this is a valid sequence
2 Consider the binary search tree BST below where each
node has a label Note that the label is notthekey Assume
that all the keys are distinct
Which are the nodes with minimum andmaximum keysrespectively
What is the heightof the node N3
What is the depth of the node N5
Find the successor of the nodes N9 N3 and N10
Find the predecessor ofthe nodes N9 and N5
, List the nodes using the inordertree walk
List the leaf nodes
Write the resulting BST afterdeleting the node N3
N1
N2 143
NH N5 NG N7
9 NIO NII
N8
112
minimum key N4
maximum key NII
height of the node N3 is 3
depth of the node N5 is 2
successor of N9 is N6
110 nia
N5 is N1
predecessor of
Y is this
In order tree walk
Ny N2 NS NS N1 N19 NG N 3 Nio N12 N7 N1
Leaf nodes
414 No N9 N 2 NY