Exercises - Lecture 8

8A

For the first two problems, consider the following five structures, which can be referred to by the label of their root elements (A through E):

  1. Which of the above are trees?
  2. Which of the above are binary trees?

8B

For all remaining exercises in this set, refer to the tree pictured below:

  1. What’s the root of G’s right subtree?

  2. List the ancestors of F.

  3. What’s C’s parent?

  4. List the nodes at depth 1?
  5. List the nodes that are the root of a subtree of height 0.
  6. What’s the height of the tree rooted at G?
  7. What’s the depth of node D?

8C

  1. Write the nodes in the order they are visited by a pre-order traversal.
  2. Write the nodes in the order they are visited by a in-order traversal.
  3. Write the nodes in the order they are visited by a post-order traversal.