Question: Implement a template class Unsorted List as defined by the following skeleton: #define MAX_ITEMS 10 typedef char Item Type: class Unsorted List { private: int


Implement a template class Unsorted List as defined by the following skeleton: #define MAX_ITEMS 10 typedef char Item Type: class Unsorted List { private: int length; Item Type values[MAX_ITEMS); int currentPos; public: SortedList(); // default constructor: lenght=0, currentPos=-1 void MakeEmpty; // let length=0 void InsertItem(Item Type x); // insert x into the list void DeleteItem(Item Type x); // delete x from the list bool IsFull(); // test if the list is full int Lengthis(); // return length void RetrieveItem(Item Type &x, bool &found); // retrieve x from the list, the // boolean result is stored in found void ResetList(); // currentPos=-1 void GetNexttem(Item Type &x); // get the next element from the list with // respect to the currentPos void printElement(); // print out the values of all the list elements, separated by // a white space You need to use linear search in InsertItem(), DeleteItem() and RetrieveItem(). You should create one instances of this class and read in data from a file: char.dat, which can be downloaded from cis 200 web site and are assumed to be in the root directory of your project. Data in char.dat contains chars, which should be inserted into the object of UnsortedList. Note the you do not have any prior knowledge about how data values in char dat You also need to write a subroutine, int numCharElement(ifstream &x), to determine the number of char elements in char.dat. The skeleton of main() should be: Int main() { Unsorted List x; // open char.dat // set up x based on the data in char dat X.printElement(); cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
