CS 153 Data Structures I
Programming Assignment #4
Due: 2/8/01
This programming assignment is designed to:
-
build on assignment #3 by only changing how the integer data
is stored within the bag
-
introduce the use of a linked list
-
introduce the use of address pointers
In order to meet these goals you may:
-
use program #3 as a starting point
-
create a new folder named Project4
-
copy everything from your Project3 folder into the new folder
-
remove the int data array from the class CBag definition
-
define (in Bag.h ahead of class CBag) a struct named Node
-
int data;
-
Node * next;
-
NODE() //a constructor for a Node
-
{ data = whatever;
-
next = NULL;
-
}
-
modify each of the Bag::functions to work with the linked list instead
of the array
The behavior of your program should be EXACTLY as it was in #3, except
for CBag::Full():
By using a linked list data structure you have create a dynamic storage
mechanism that will grow as the program runs. The only condition
that should cause the bag to be full would be that of running out
of memory.
You will be shown in class how to test for running out of memory.
For this assignment we do not expect you to test for this condition.