Professional Documents
Culture Documents
1.
A. Based on the binary search tree in figure above, answer the following questions.
6 15
4 7 12
C. Redraw the tree in figure after 2 nodes with value 22 and 30 is inserted into the tree
19
10 24
6 15 20 40
4 7 12 22 30
D. Give the inorder, perorder and postorder of the tree traversal.
Inorder: 4 6 7 12 15 10 19 22 20 24 40 30
Perorder: 19 10 6 4 7 12 15 24 20 22 40 30
Postorder: 4 7 12 6 15 10 22 20 30 40 24 19
2. Draw a binary search tree if the following sequence of input value were inserted.
15,19,17,6,8,12,7,3,20,2,5
A. Identify the characteristics of the binary search tree drawn above (complete binary tree/ Full
binary tree/ Balanced tree).
15
6 19
3 8 17 20
2 5 7 12
B. Given the following binary search tree, answer the following questions:
i. Redraw the tree after node K has been deleted from the tree.
D R
H M
P
Delete the left most node of the right subtree and put it at position K
iii. Referring to the original tree, redraw the tree after node R and NA have been deleted
consequently.
K
K
D V D V
H M H P
L P
L
C. Given the inorder, perorder and postorder traversal of the following binary search tree.
Inorder= C*A+B+D*F*G+H
Preorder= +*c+AB**+GHFD
Postorder= CAB+*GH+F*D*+
D. The function below is a destructor function for a Tree that destroys all nodes in binary tree. The
destructor will call a function named Destroy () that will be implemented recursively. Based on the tree
in the figure, explain how the nodes in the tree are destroyed and list the order of the nodes in the tree
being destroyed starting from the first node to the last node.
D>L>1>G>P>S>W>R>M