Total = 30 points
Use the binary tree above to answer the following questions.
1. What is the height of this tree? [2 points]
The deepest node, 15, is at depth 4. The height of a tree is 1 more that the depth of the deepest node; so, the height of this tree is 5.
2. What is the depth of the node labeled 60? [2 points]
The depth of the node labeled 60 is 2. That is the path from the root to this node contains two edges, and the depth of a node is the length of the path from the root to the node.
3. List all the nodes that are leaf nodes. [4 points]
A leaf node is one that has no children. The leaf nodes are the set { 15, 40, 65, 80 }
4. List a node that is an ancestor of the node labeled 40. [2 points]
Either 30 or 50 is an ancestor of the node labeled 40.
5. Are the nodes labeled 40 and 60 siblings ? [2 points]
No. Siblings have a common parent, but 40 and 60 have different parents. They are, however, cousins.
IS 320, Assignment 3 Answer Key Page 1 Spring, 2016
6. Which node is the root? [2 points]
The root node is the node labeled 50.
Assume the visit procedure for a traversal algorithm prints the value of the node.
7. What is the result of an in-order traversal? [4 points]
10, 15, 20, 30, 40, 50, 60, 65, 70, 80, 90
8. What the result of a pre-order traversal? [4 points]
50, 30, 10, 20, 15, 40, 70, 60, 65, 90, 80
9. What is the result of a post-order traversal? [4 points]
15, 20, 10, 40, 30, 65, 60, 80, 90, 70, 50
10. What is the result of a breadth-first traversal? [4 points]
50, 30, 70, 10, 40, 60, 90, 20, 65, 80, 15
IS 320, Assignment 3 Answer Key Page 2 Spring, 2016