Comp 121 Introduction to Data Structures.
Fall 2000Programming Assignment 2 -- Due October 24, 2000
As discussed in class, a dynamic dictionary is an abstract data type which supports the following public interface:
template <class keyType, class dataType>
class dictionary
{
public:
dictionary(int size);
~dictionary();
bool isEmpty() const;
bool isFull() const;
void insert(keyType k, dataType x);
//insert if not already present; else updatevoid remove(keyType k);
//remove if presentbool find(keyType k, dataType &x);
//return true if present, and place data in xvoid printSorted() const;
//print ordered pairs (key, data), sorted by key};
Implementing a dynamic dictionary. You are to provide a complete binary search tree (BST) based implementation of the dynamic dictionary ADT. Use an array for internal representation of the BST, based upon the cursor implementation method discussed in class.
Counting word frequencies. Using your dynamic dictionary, write a utility that reads in a text file specified as a command-line argument, and prints out (on standard output) a lexicographically-sorted list of all the words that occur in this file alongwith the frequency with which each word occurs. (This requires you to familiarize yourself with (i) command line arguments, and (ii) the string-manipulation package <string>.)
Rules for submitting this (and future) programs:
All of the above should be placed in an envelope with your name on the outside, and submitted at the beginning of class on the due date. Submissions will not be accepted after 10 minutes have elapsed from the start of class no late submissions will be accepted without documented reasons.