Assignment 08
Contents:
Overview
Topic: Data Structures
Related Reading:
Ch. 7.1-7.2, 7.5 of [Br].
(skip second half of p. 326 and all of p. 331).
Due: 8pm Thursday, 28 March 2002
Internet Requirements
You will only need an internet connection at the time of submission.
Practice Problems
Problems to be Submitted (20 points)
- (5 points)
Consider representing the following two-dimensional array using
15 consecutive cells of memory. The placement of the individual
characters depends on whether the array is represented in row major
order or column major order.
Q |
W |
E |
R |
T |
Y |
U |
I |
O |
P |
A |
S |
D |
F |
G |
- How would the characters be arranged in memory if using row major
order?
- How would the characters be arranged in memory if using column major
order?
- Most characters do not remain in the same memory cell when
switching from row major to column major order. However, there
are three characters which do remain in the same cell, no matter
which of the two orders is used. Which three characters?
- (9 points)
The following data is actually a representation of a linked list.
Each "node" of the list is represented using two cells of memory. The
first of the two cells stores a letter of the alphabet and the second of
the two cells stores a "pointer" to the cell of memory which begins
the following node in the linked list.
In this example, we will store a single character as the data for each
node. The "head" of this particular list begins with the entry at
cell 7. A pointer value of zero 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 |
-
Give the sequence of characters contained in the linked
list, beginning with the "R" stored at the head of the list in cell 7.
- We would like you to insert the letter "G" into the linked list so
that it is sequenced between the letter "T" and the letter which
originally follwed "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.
-
Having inserted "G" from the previous step, please continue by
performing a deletion the entry containing "W" from the list. Please
show the contents of all memory cells after the deletion
has been performed.
- (3 points)
Chapter 7 Review Problem 24 (pp. 364-365 [Br])
- (3 points)
Chapter 7 Review Problem 28 (p. 365 [Br])
The "diagram" you submit should be text which shows the memory cell numbers and
contents, similar in spirit to Figures 7.19 and 7.20
(pp. 345-346 [Br]).
Overall, please place your answers to all of these questions in a
single document to be submitted.
Extra Credit (2 points)
The extra credit involves gaining a deeper familiarity with the
recursive PrintTree procedure of Figure 7.24 of [Br]. Practice
problems for this topic include Question 6 of Ch. 7.5
(p. 352 of [Br]), as well as Chapter 7 Review Problems 26
and 31 (p. 365 of [Br]).
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 Question 1 on page 352 of [Br].
(Note: you do not need to do that question, we simply wanted to use
that tree as an example)
comp150 Class Page
mhg@cs.luc.edu
Last modified: Mon Mar 18 21:22:28 CST 2002