CS 367 - Introduction to Data Structures - Section 3

Programming Assignment Zero: Bags

Due Thursday, Setember 18, 1997 by 2:30pm

Contents


Motivation

This assignment concerns the implementation of a few member functions of the Bag abstract datatype discussed in class. The assignment is not meant to be particularly difficult or time consuming. It is meant to:

Requirements

You have three requirements for this assignment:
  1. Write isEmpty and isFull functions that match the specifications given in bag.h. This should allow the test program to compile and avoid undesired calls to grab and insert.
  2. Add checks to grab and insert to prevent an unwise user from getting unpredictable results by neglecting to meet the preconditions.
  3. Implement the equality operator (==) for bags. We define two bags to be equal if they have the same contents - each item present in one bag is present in the same quantity in the other bag. This operator must meet the specification given in bag.h. (It is currently incorrectly implemented to automatically return false, just so that the program compiles upon completion of part 1.) Make sure that you include comments describing how the function works.

Grading

The program will be graded on an 100 point scale, weighted as follows: I cannot stress enough the importance of documentation - poorly documented programs may be graded harshly. For more information on grading policy, click here.


Files

There are four files you will need to do the assignment, found in ~cs367-3/public/Assignments/Zero/Files: You can copy the files by viewing the documents in Netscape and then using the Save As option from the File menu. Alternatively, you can simply copy them to the directory of your choice. For example to copy them to the directory ~foo/cs367 you can type:
cp ~cs367-3/public/Assignments/Zero/Files/* ~foo/cs367
The code provided is based on that in Main & Savitch, particularly Section 3.1 and part of Section 5.3. You need only modify bag.C.


How to get started

Keep editing, compiling, and testing (the so-called edit-compile-debug cycle) until you have met all the requirements. When finished, submit the file electronically. Don't forget to add comments wherever necessary.


Submitting

What we need once you are done: Copy your modifed version of the file bag.C to the directory ~cs367-3/Submissions/Zero/<login> where <login> is your login name. For example if your login name is foo, then from the directory where your modified bag.C file is located, type:
cp bag.C ~cs367-3/Submissions/Zero/foo 
This is a paperless assignment. You need only turn in the program electronically.


Solution

A solution will be made available after we have "closed the door" to accepting more assignments. (This should be the same time as the due date - see the late policy below.) A compiled executable derived from the soliton is available for you to try out. The solution executable is located in ~cs367-3/public/Solution/Zero and is called baggage.

The instructor's solution to Programming Assignment Zero is now on-line.


Late Policy

This is not a difficult assignment. Late assignments will not be accepted. If you feel you truly have a justifiable excuse for turning in the assignment late, you must clear it with me at least one day in advance. (I do not plan on clearing any such requests.)