CS 215 - Fundamentals of Programming II

Spring 2006 - Programming Project 5

20 points

Out: March 15, 2006
Due: March 22, 2006



This project consists of writing two short applications, one that uses STL vectors and STL lists and one that uses STL stacks.

Part I: Creating a concordance

(10 points) Since a list must be searched sequentially, when a list grows to be large, finding a value in the list it not efficient. One way to improve efficiency is to maintain several smaller lists. For example, a text concordance is a list of all distinct words appearing in a particular text. Write a program in the file concordance.cpp that reads words in uppercase (only) text and produces a text concordance. (We will ignore lowercase and punctuation for this program.) The program must meet the following criteria:

This program must take two command-line arguments, the input file name and the output file name. You will write your own test files. You must submit 1 non-trivial test file. By non-trivial, we mean a test file of at least several lines, with words beginning with a variety of letters, and with duplicates. Please note that there should be no punctuation, no digits, and no lowercase. Name this file sampletext.txt.

Part II: Checking for matched delimiters

(10 points) Using a stack, write a program in the file match.cpp that reads (non-whitespace) characters one at a time from a file, and determines if the delimiter pairs ( ), { }, and [ ] in the file match up properly. (I.e., it ignores all other characters.) Delimiters match properly if, for each left delimiter, there is a corresponding right delimiter, and the pairs are properly nested. For example,

The output from this program should be written to the screen and be one of:

This program must take one command line argument, the input file name. You will write your own test files. You must submit 2 non-trivial test files, one where the delimiters match and one where the delimiters do not match. By non-trivial, we mean a test file larger than the examples above, including characters other than the delimiters, and of more than one line. Name them matched.txt and unmatched.txt, respectively. One input test file you might try is a very simple C++ source file without comments or string literals. (Properly written C++ code should have matched delimiters. However, it is possible to have unmatched delimiters in comments and string literals.)


You are not required to submit a makefile for either program. Submit a tarfile containing concordance.cpp, sampletext.txt, match.cpp, matched.txt, and unmatched.txt. Turn in a hardcopy of concordance.cpp and match.cpp (only).


Follow the guidelines in the C++ Programming Style Guideline for CS 215 handout. As stated in the syllabus, part of the grade on a programming project depends on how well you adhere to the guidelines. The grader will look at your code listing and grade it according to the guidelines.


REMINDER: Your project must compile for it to be graded. Submissions that do not compile will be returned for resubmission and assessed a late penalty.



Converted using latex2html on Tue Mar 14 21:49:19 CST 2006