Assignments | Class Photo | Computing Resources | Course Home | Lab Hours/Tutoring | Schedule | Submit

Saint Louis University

Computer Science 180
Data Structures

Michael Goldwasser

Fall 2008

Dept. of Math & Computer Science

Homework Assignment 06

Trees

Contents:


Overview

Topic: Trees
Related Reading: Ch. 8
Due: Friday, 21 November 2008, 10:00am

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


Problems to be Submitted (20 points)

  1. (4 points)

    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 at least as large as its children's). Draw a picture of the tree structure that results at the conclusion of the following sequence of operations:

    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)

  2. (4 points)

    Based on your answer to the previous question, show the subsequent result after performing the additional operations:

    pop(), pop()

  3. (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
          

  4. (4 points)

    Draw a binary tree T such that simultaneously,

  5. (4 points)

    Consider the tree shown in Figure 8.13 on page 467. If erase were called on the node with data "that", based on the code we provided in class, 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).


Michael Goldwasser
CSCI 180, Fall 2008
Last modified: Friday, 14 November 2008
Assignments | Class Photo | Computing Resources | Course Home | Lab Hours/Tutoring | Schedule | Submit