Course Home | Homework | Lab Open Hours | Programming | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 180
Data Structures

Michael Goldwasser

Spring 2007

Dept. of Math & Computer Science

Homework Assignment 05

Trees

Contents:


Overview

Topic: Trees
Related Reading: Ch. 8
Due: Wednesday, 2 May 2007, 2:10pm

Please make sure you adhere to the policies on academic integrity.


Problems to be Submitted (20 points)

  1. (4 points)

    Consider the tree shown on the left side of Figure 8.6 (page 452).

  2. (4 points)

    On page 463 of Section 8.3, the text discusses how a binary tree can be dumped to text using a preorder traversal, providing an unambiguous representation which can later be used to reconstruct the tree. Demonstrate this principle by drawing a picture of the tree that produced the following text representation:

    T
    R
    NULL
    A
    V
    NULL
    NULL
    E
    R
    NULL
    NULL
    NULL
    S
    A
    NULL
    NULL
    L
    NULL
    NULL
          

  3. (4 points)

    Draw a binary tree T such that simultaneously,

  4. (4 points)

    Consider the tree shown in Figure 8.13 on page 467. If erase("that") were performed based on the code in the text, what would be the resulting tree?

    Note: for ease in providing your solution, you should show the entire subtree rooted at "rat" (but you do not need to draw the left portion of the original tree; that part is unchanged).

  5. (4 points)

    It has been a while since we discussed the heap implementation of a priority queue. Please review the general algorithms as described on pages 484-487 of Section 8.5 (you need not concern yourself with the low-level code which is later developed).

    Assume that we start with an initially empty "max heap" (a heap where key of each parent is larger than its child). Show the final heap which results at the very end of the following sequence of keys:

    push(18), push(23), push(16), push(25), push(10), push(19), push(24), push(12), push(22), push(27), push(13), push(17), push(26), push(21).
    (you do not need to show all the intermediate calculations so long as your final result is correct)


Michael Goldwasser
CSCI 180, Spring 2007
Last modified: Saturday, 28 April 2007
Course Home | Homework | Lab Open Hours | Programming | Schedule & Lecture Notes | Submit