Computer Science 245
Spring 2009
Homework 3:  Tree Traversals & Heaps
Due Wednesday, February 25th, 3:30 p.m.

  1. For each of the following trees, show the order that the nodes will be visited in a PREORDER, INORDER, and POSTORDER traversal:
    • Tree 1:

      Tree1

    • Tree 2:
      Tree2
    • Tree 3:
      Tree3

    • Tree 4:
      tree4
  2. Draw all possible trees with the following PREORDER traversal:

    A B C

  3. Draw all possible trees with the following POSTORDER traversal:

    A B C

  4. How many different trees have the following PREORDER traversal?  You don't need to give all of the trees, just count them.

    A B C D

  5. The following elements are inserted (in this order) into a min heap:

    8 7 4 6 2 5 3 1

    Show the resulting heap

    Show the heap after 3 removemin operations