Assignments | Course Home | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 140
Introduction to Computer Science

Michael Goldwasser

Fall 2006

Dept. of Math & Computer Science

Assignment ظ
Data Structures

Contents:


Overview

Topic: Data Structures
Related Reading: pp. 213-215, 224-232, Ch. 8.1-8.3 and notes
Due: 8pm Monday, 30 October 2006


Internet Requirements

You may want an Internet connection for several practice problems. However you do not necessarily need the connection for completing the assignment, other than for submission.


Practice Problems


Problems to be Submitted (20 points)

  1. (3 points)

    Fill in the missing values for the following memory contents in a way so that it represents a linked list containing the sequence of characters "ANSWER". Which cell is the head of your list?

    Memory Contents
    (in decimal)
    Cell 1 2 3 4 5 6 7 8 9 10 11 12
    Value R W E S A N

  2. (9 points)

    The following data is a representation of a linked list. The "head" of the list is at cell 7. A pointer value of 0 designates the end of the list.

    Memory Contents
    (in decimal)
    Cell 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    Value Q 0 W 11 E 12 R 3 T 15 Y 9 U 13 P 1

    1. Give the sequence of characters contained in the linked list, beginning with the "R" stored at the head of the list in cell 7.

    2. We would like you to insert the letter "G" into the linked list so that it is sequenced immediately following the letter "T" in the list. (You may use any pair of cells for this new entry which were "unused" in the previous list). Please show the contents of all memory cells after the insertion has been performed.

    3. Having inserted "G" from the previous step, please continue by performing a deletion of the entry containing "W" from the list. Please show the contents of all memory cells after the deletion has been performed.

  3. (4 points)

    Chapter 8, Review Problem 30 (p. 387)

  4. (4 points)

    As an example, consider the binary search tree shown in part (b) of Figure 8.24 of page 374.

    1. If D were inserted into this tree, where would the entry be placed?

    2. If I were inserted into this tree, where would the entry be placed?

    3. If L were inserted into this tree, where would the entry be placed?

    4. If S were inserted into this tree, where would the entry be placed?

Overall, please type your answers to all of the problems in a single document to be submitted electronically. Please see details about the submission process.


Extra Credit (2 points)

  1. The extra credit involves gaining a deeper familiarity with the recursive procedure for printing the information in a binary tree, as described by the PrintTree algorithm on p. 373. Though this is described in relation to a binary search tree, the procedure can be used on an arbitrary binary tree.

    Your extra credit task is the following. We want you to trace through the recursive execution of the procedure PrintTree when applied to the tree which is displayed in Chapter Review Problem 35 on p. 387 (you do not need to do that problem; we're just using that tree as an example).

    As demonstrated in the chapter, the procedure PrintTree will get applied many times with varying parameters. Also, there is a difference between the order in which each node becomes the parameter for a call to the PrintTree routine and the order in which nodes get written to output by the Print command.

    1. Please give the exact sequence of calls to this routine, reporting the root of each subtree in the order the applications are applied. For example, the first call is to PrintTree(tree rooted at Z); the second call is to Print(tree rooted at T).

    2. The only output generated by the procedure is from the command Print command within the body of that routine. In what order will the values be printed to output, when starting the process on the original tree?

      Hint: You will find that this is NOT the same order as you report for the previous question. For example, "Z" is NOT the first data in the output.


CSCI 140, Fall 2006
Michael Goldwasser
goldwamh at our university domain

Last modified: Friday, 20 October 2006
Assignments | Course Home | Schedule & Lecture Notes | Submit