
CScD-320, Algorithms
Homework 4
Options for submission:
In class: Thursday, 1 May
Assignment box: Friday, 2 May
Solution Set
1. Consider the tree in the figure on the right. What
node or nodes is/are
a. The tree’s root
40
b. Leaves
10, 30, 50, 70
c. Parents (i.e., of any node, showing child nodes)
in the format (parent: child[, child])
(40:20, 60), (20: 10, 30), (60: 50, 80), (80: 70)
d. Siblings
(20, 60), (10, 30), (50, 80)
e. Ancestors of 70 [note: parents are ancestors]
80, 60, 40
f. Descendants of 60 [note: children and …]
50, 80, 70
2. Give the height and depth of each node of the tree in the figure (either as a table or by drawing
the tree and write height and depth information beside each node).
3. Give the following traversals for the tree in the figure above:
a. Preorder 40 20 10 30 60 50 80 70
b. Inorder (since it is a binary tree) 10 20 30 40 50 60 70 80
c. Postorder 10 30 20 50 70 80 60 40
d. Level order (breadth-first) 40 20 60 10 30 50 80 70
4. Give the following traversals for the general tree to the
right:
a. Preorder A B E F C G D H J
b. Postorder E F B G C H J D A
c. Level order (breadth-first) A B C D E F G H J
5. Draw this general tree as its associated binary tree.