Computer Science 240 :: Advanced Programming

Collections


NOTE: This project is divided into two parts (Part I and Part II). For the Programming Exam you only need to complete Part I. Part II will be completed after the Programming Exam.

Overview

Most non-trivial programs use data structures to store and access information. Common examples are lists, stacks, queues, trees, etc. Data structures are also called "collections" because they are used to manage groups (or collections) of objects. For this assignment you will write two collection classes in C++. You will write a class named LinkedList that implements a doubly-linked list and a class named BST that implements a binary search tree. Unlike the previous projects, you will not be asked to deliver a complete running program. Rather, the deliverables for this project are just the LinkedList and BST classes. To pass off your project, we will take your classes and compile and link them with a test program that will exercise your code and verify that it works. It is your responsibility to test your code and make sure that it works before passing off.

Project Files

Header files for the LinkedList and BST classes are provided at the following links:

LinkedList.h

BST.h

Your task is to implement all of the methods on the LinkedList and BST classes according to the comments in the header files. You should place your LinkedList and BST implementations in files named LinkedList.cpp and BST.cpp, respectively. You should not modify the public interfaces of the classes. If you do, the test program that will be used to pass off your code will not compile. You may (and probably should) modify the .h files to add private method and variable declarations, but your method bodies should go in the .cpp files.

The test program will assume that your files are named LinkedList.h, LinkedList.cpp, BST.h, and BST.cpp Since Linux file names are case sensitive, capitalization does matter.

Restrictions

For this project you are allowed to use the C++ string class defined in the <string> header file (in fact, you must use it to make your code work).

You are not allowed to use the classes and functions from the Standard Template Library (vector, list, map, set, etc.). Specifically, the following header files may not be used:

Part I

Implement all of the methods on the LinkedList and BST classes.

For Part I your code will not be tested for memory management errors. That will come in Part II.

Part II

Ensure that your code does not contain any memory management errors, as described in the Memory Management Errors section of the Project I specification. The TAs will use valgrind to check your code for memory-related errors when you pass off. You should run valgrind on your code and fix any reported bugs before attempting to pass off.

Not all memory errors are your fault and there are cases of false positives. We offer a file to suppress these for you.