Pages

Monday, 3 October 2011

problem Assignment

Problems
Your task is to extend the List class which is given in the example program in the handouts of Lecture No. 03 by writing one method for removing successive duplicate items from lists, and one method for adding them. The squish() method and twin() method will operate on singly-linked lists.
 
Here is the detail about these functions.
 
squish( ) 
The squish() method performs as described below. 
 
squish() takes the list and, wherever two or more consecutive items are equal, it removes duplicate nodes so that only one consecutive copy remains.  Hence, no two consecutive items in this list are equal upon completion of the procedure. After squish() executes, the list may well be shorter than when squish() began.  No extra items are added to make up for those removed.
 
For example, if the input list is [ 0 0 0 0 1 1 0 0 0 3 3 3 1 1 0 ], the output list is [ 0 1 0 3 1 0 ].
   
Here is the prototype of the squish() function that you will use in your code.
 
List squish(List list);    
 
twin( )
The twin() method performs as described below.  
 
twin() takes the list and doubles its length by replacing each node with two consecutive nodes referencing the same item. For example, if the input list is [ 3 7 4 2 2 ], the output list is [ 3 3 7 7 4 4 2 2 2 2 ].
 
Here is the prototype of the twin() function that you will use in your code.
   
List twin(List list);
 
Note:  Your Submission must include:

1. A working MakeFile (Dev-C++ project File).
2. All the Source Code(.h and .cpp files) necessary to compile and run your program.
3. Upload all the files on VULMS in a zip folder.

Note: Use Dev-C++ 4.9.7.0 which is available at VULMS.