Due: Thursday 11/9/2006 at 11:59 pm
For this assignment, you must implement four linear data structure using linked lists in either C++ or Java. All four of these data structures are to be connected in some inheritance hierarchy. Therefore you are not allowed to create 4 complete separate data structures for this assignment. Any assignment doing this will receive a zero for the assignment.
The following shows the classes and methods that are to exist. You will most likely also need a Node class.
The following is to clarify any of the operations.
Create a new list specified by <type> for list <num>.
The values of <num> will be the integers of 1, 2, 3 or 4.
The values of <type> will be the characters of u, o, q or s.
When a new list is created, the previous list should be emptied of its nodes (i.e. write a method to deallocate the previous list). If you wish, the 4 lists can be created when the program begins to whatever list type you desire. This way a user can call the insert command before the create command and not cause an error.
Insert the integer <value> into list <num>.
The values of <num> will be the integers of 1, 2, 3 or 4.
The values of <value> could be any integer.
For the insert operation on the unordered list, insert the value at the head of the list. For the ordered list, the smallest value should be at the beginning of the list. For a queue, insert at the end. For a stack, insert at the beginning of the list.
List an value from list <num>.
The values of <num> will be the integers of 1, 2, 3 or 4.
For the listValue operation for the unordered list and sorted list, the method being executed is to prompt the user for a position and then display the the value at that position in the list of the item. The head of the list is position 1. For the queue and stack, display the value at the beginning of the list.
Remove an value from list <num>.
The values of <num> will be the integers of 1, 2, 3 or 4.
For the remove operation for the unordered list and the sorted list, the method being executed is to prompt the user for the position of the node to be removed. A value of 1 should remove the value a the head of the list. For the queue and the stack, remove the value at the beginning of the list.
Display the size of list <num>.
The values of <num> will be the integers of 1, 2, 3 or 4.
For the size operation, return the number of nodes in the list. Even though such an operation is normally not included with a queue or a stack, we will allow this operation for the project.
Print all the values from list <num>.
The values of <num> will be the integers of 1, 2, 3 or 4.
The print operation is list all of the items in the list with the beginning of the list shown first.
Print some help about the commands used for this program.
Print some information about the creator of this program. You should always identify your code.
Quit this program.
c 1 q not c <1> <q>
Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.
The work you turn in must be 100% done by your own own. You are not allowed to share code with any other students (inside this class or not). You may discuss the project with other students; however, you may not show any code you write to another student nor may you look at any other student's written code.
You are to submit this using turnin on the CS Department machines with the project name of mp4. The turnin command would be
turnin -c cs340 -p mp4 <filename(s)>Where <filename(s)> would be the name of the file(s) you want to submit for grading. You can verify what you submitted by using the command:
turnin -c cs340 -p mp4 -v