CS 215 - Fundamentals of Programming II

Spring 2008 - Homework 8
25 points


Out: April 9, 2008
Due: April 16, 2008


Answer the following exercises from the textbook. When a question says “implement” just write the implementations on paper. You do not need to type the code into the computer (unless you want to, of course).


  1. (2 points) Exercise 18 on page 576.

  2. (4 points) Exercise 20 on pages 576-577. Note: part (c) should say that postorder scan is LRN, not RLN.

  3. (4 points) Exercise 21 on page 577.

  4. (2 points) Exercise 23 on page 577.

  5. (4 points) Exercise 26 on page 578. Note: the tree is a binary search tree, and the original tree is to be used for each part.

  6. (3 points) Exercise 27 on page 578. Note: the sequence given is the sequence of insertions into the binary search tree.


Answer the following questions. Note: the resulting binary trees are not search trees.


  1. (3 points) The preorder scan output of a character binary tree produced

    A D F G H K L P Q R W Z

    and the inorder scan output of the same binary tree produced

    G F H K D L A W R Q P Z

    Draw the binary tree.

  2. (3 points) The postorder scan output of a character binary tree produced

    F G H D A L P Q R Z W K

    and the inorder scan output of the same binary tree produced the same output as in the previous question. Draw the binary tree. (Note: this tree is not the same as the tree in the previous problem. These exercises show that multiple trees can produce the same inorder scan, but combined with a preorder or postorder scan, one can determine a particular tree.)


04/08/08 1 of 1