(Latest Revision: 03/14/2004)
Book Collection Program
RATIONALE:
Writing this program will help you get a deeper understanding of
binary search tree implementation issues. Also it will give you
practice designing a new data structure.
THE ASSIGNMENT:
Write a program that keeps track of a book collection, allowing
fast access by three different keys: title, author, and subject.
It must simultaneously maintain the list in alphabetical order
by all THREE keys.
INPUT:
The program inputs a series of commands from standard input. The
commands are described in detail below.
The program must not expect any other input.
OUTPUT:
After reading each command the program echoes the command to
standard output. It then executes the command and prints an
appropriate response to the command on standard output.
The program also writes separator strings to standard output to
separate the outputs corresponding to each input command.
The program must not write output of any other kind.
COMMANDS:
Input to the program will consist of a series of commands in
the following forms.
Note: arguments like <subject> stand for VARIABLES which
are strings terminated by end-of-line. Strings will have
arbitrary amounts of leading, embedded, and trailing white space.
The internal representation of the strings however are required
*not* to have leading or trailing whitespace, and to have only
single blanks between "words." (Here, a "word" is a contiguous
string of characters that are not white space -- so something
like the L. in L. Frank Baum would be called a word.)
Command names given below, like Insert, are literals and will
appear in the input file exactly as they appear below.
COMMAND FORM:
Insert <author>
<title>
<subject>
SPECIFIC EXAMPLE:
Insert L. Frank Baum
The Wizard of Oz
Children's Fantasy
EXAMPLE OF THE CORRESPONDING OUTPUT:
Insert L. Frank Baum; The Wizard of Oz; Children's Fantasy
... insertion complete ...
============================================================================
This command adds another book to the collection. It allocates a
node, copies the data into it, and links the node into a
structure that is three BST's in one. The structure
simultaneously maintains the nodes in order by author, subject,
and title. The details of the desired structure will be
explained in class.
Note that in the real world two books can have the same author,
or the same title, or the same subject. Your program must do
something reasonable when there is a "tie" between two keys.
To avoid some of the potential technical details, however, we
will assume that titles are unique.
COMMAND FORM:
Delete <title>
SPECIFIC EXAMPLE:
Delete The Wizard of Oz
EXAMPLE OF THE CORRESPONDING OUTPUT:
Delete The Wizard of Oz
... deletion complete ...
============================================================================
This command must cause a search for the named book. If the
book is found, the pointers must be updated so that the book is
now deleted from the multi-tree structure.
Note: You have to remove the node from three trees, one after the
other. This constraint introduces a subtle difficulty: You
can't use the "copy trick" described in our textbook to simplify
the case of deleting a node that has two children. Do you see
why?
We will discuss this issue in class.
If the book is not found, the procedure must leave the list and
pointers unchanged, and simply print an appropriate message to
the user.
COMMAND FORM:
List by <key>
SPECIFIC EXAMPLE:
List by title
EXAMPLE OF THE CORRESPONDING OUTPUT:
List by title
Andrew Tannenbaum
Structured Computer Organization
Computer Architecture
Douglas Comer
The Internet Book
Communications
L. Frank Baum
The Wizard of Oz
Children's Fantasy
Bruce Eckel
Thinking in C++
Programming Languages
============================================================================
This command must print out the contents of each indexCard in the
list, in order according to the indicated key. The key can be
either author, title, or subject. Use an attractive format.
If the list is empty, an appropriate message must be printed.
COMMAND FORM:
PrintTree by <key>
SPECIFIC EXAMPLE:
PrintTree by author
EXAMPLE OF THE CORRESPONDING OUTPUT:
PrintTree by author
Andrew Tannenbaum
Structured Computer Organization
Computer Architecture
Bruce Eckel
Thinking in C++
Programming Languages
Douglas Comer
The Internet Book
Communications
L. Frank Baum
The Wizard of Oz
Children's Fantasy
============================================================================
This command traverses the tree structure in reverse in-order and
prints a "sideways" representation of the tree structure.
COMMAND FORM:
Quit
SPECIFIC EXAMPLE:
Quit
EXAMPLE OF THE CORRESPONDING OUTPUT:
Quit
Quit command received ... exiting.
============================================================================
This command must cause the program to Halt.
HELP:
Come to class to get help and hints.
WHAT TO TURN IN:
You will turn in three "phases" of this assignment:
- a level 2 version, and
- a level 3 version, and
- a final version.
For each phase of the assignment, you will turn in a printer output (hardcopy)
and you will send me an e-mail message. Please follow these rules:
- Always send me e-mail as plain text in the main message body.
Never send me attachments.
- Always use the exact subject line I specify for each
message. (I often get hundreds of e-mail messages in a week. The
subject line allows me to find, filter and sort messages.) You will lose
a significant number of points on the assignment if you use the wrong
subject line.
- Be very careful when you send the e-mail. You may use the
instructions in your
Hello World! lab excercise
for guidance. Of course, you will need to make the obvious changes to
those directions -- you have to use the correct subject line and
filename.
- Always send yourself a copy of each e-mail message you send to me,
and check immediately to see if you receive the message intact.
You are responsible for sending
e-mail correctly.
Here is the list of things you have to turn in:
- At the start of class on the
first due date,
place the following item on the "counter" in front of me:
- a hardcopy of your level 2 (or
greater) program. (All the source code, i.e. all the *.h and *.cpp
files) Make sure all the code is properly formatted and that it all
shows on the paper.
- Using the subject line: CS3100,prog3.2 send the following item
to me by e-mail before midnight on the
first due date:
One
shell archive file
(only one) containing items 1-4.
- All source files for your level 2
program (everything I will need to compile and run it:
all *.cpp files and *.h files)
- Your test script showing adequate testing of your level 2 program.
- A file named 'README' containing the compilation command one should
use to compile your program.
- A copy of your 'makefile' if you used one.
- At the start of class on the
second due date,
place the following item on the "counter" in front of me:
- a hardcopy of your level 3 (or
greater) program. (All the source code, i.e. all the *.h and *.cpp
files) Make sure all the code is properly formatted and that it all
shows on the paper.
- Using the subject line: CS3100,prog3.3 send the following item
to me by e-mail before midnight on the
second due date:
One
shell archive file
(only one) containing items 1-4.
- All source files for your level 3
program (everything I will need to compile and run it:
all *.cpp files and *.h files)
- Your test script showing adequate testing of your level 3 program.
- A file named 'README' containing the compilation command one should
use to compile your program.
- A copy of your 'makefile' if you used one.
- At the start of class on the
third due date,
place the following item on the "counter" in front of me:
- a hardcopy of your final level
program. (all the source code) Make sure all the code is properly
formatted and that it all shows on the paper.
- Using the subject line: CS3100,prog3.f send the following item
to me by e-mail before midnight on the
third due date:
One
shell archive file
(only one) containing items 1-4.
- All source files for your final level
program (everything I will need to compile and run it:
all *.cpp files and *.h files)
- Your test script showing adequate testing of your final level program.
- A file named 'README' containing the compilation command one should
use to compile your program.
- A copy of your 'makefile' if you used one.
Note that there are no spaces in the subject lines given. It is important
that you do not insert any spaces. My e-mail address is: john@ishi.csustan.edu.
DUE DATES:
For due dates, see
the class schedule.