COSC 173: Data Structures

Project 4
Spring 2004

Due: Nov 19 @ 5:10 PM
10 points

Implement Cormen et al.'s B-tree algorithms as the class BTree<T>. It must be a template class. The constructor must take t, the order of the B-tree, as a parameter. You can assume that you'll be storing only the key, which will be a char (i.e., T = char). You must implement a destructor (or clear method).

The main function should read a set of commands from standard input (i.e., cin). The first object in the stream will be an int specifying the order of the B-tree, which will be followed by a sequence of commands: (P)rint, (I)nsert, (R)emove, and (F)ind. The last three commands take a key (i.e., a char) as an argument. The main function should read t, create a BTree<T> object of that order, and perform each operation on the B-tree. Examples of such commands follow:

3
I F
I S
F Q
I Q
I K
I C
F L
I L
I H
I T
P
R L
P
R Q
P
The Print command should print the B-tree in a pre-order fashion with each node's keys preceded by the string "Keys: ". The Find command should report that the key was either found or not found.

The previous input should produce output similar to the following:

Inserting F
Inserting S
Did not find Q
Inserting Q
Inserting K
Inserting C
Did not find L
Inserting L
Inserting H
Inserting T
Keys: K
Keys: C F H
Keys: L Q S T
Removing L
Keys: K
Keys: C F H
Keys: Q S T
Removing Q
Keys: K
Keys: C F H
Keys: S T
Instructions for Electronic Submission: You must provide a working UNIX Makefile with your submission. Use the one from P1, but modify the SRCS list. At the top of the file main.cc (or the file containing the main function), place the following header comment, with the appropriate modifications:
//
// COSC 173 Project 4
// Name: <your name>
// ID: <GoCard ID>
// E-mail: <e-mail address>
// Instructor: Maloof
// TA: <TA's name>
//
// In accordance with the class policies and Georgetown's Honor Code,
// I certify that, with the exceptions of the class resources and those
// items noted below, I have neither given nor received any assistance
// on this project.
//

Although you may use any C++ compiler to develop your program, it must run under UNIX and must compile using GNU g++. You must also provide a working UNIX Makefile for your project.

If you need to include a message to your TA about your submission, then place the message in a file named README. Place the README file in the project directory p4/.

Before submitting, to reduce the size of the zip file, type 'make clean'.

To move up from the p4 directory, type

gusun% cd ..
(Additional UNIX commands at the bottom of this page: HOWTO Compile under UNIX)

When you're ready to submit, change the name of the directory to your netid. For example, if your netid is maloofm, then rename the directory p4 by typing

gusun% mv p4 maloofm
Create a zip file of the directory and its contents by typing
gusun% zip -r p4.zip maloofm/*
This command creates a zip file named p4.zip by recursively (-r) copying all of the files (*) from the directory maloofm/.

To submit the zip file type

gusun% submit -a p4 -f p4.zip
p4 is the name of the assignment (-a) and p4.zip is the file (-f) to be submitted for that assignment.

If the program submits the file successfully, you will receive a receipt by e-mail at the address <netid>@georgetown.edu.

Submit your project only once.

Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., gusun or cssun) that preserves the modification date and time. If we lose your project or the submission system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.

You can also change the directory's name back to the original name. For example,

gusun% mv maloofm p4
Note that changing the name of the directory does not change the dates of the files in the directory. You can also remove the zip file from your directory:
gusun% rm p4.zip

You must submit your project before 5:10 PM on the due date.