# CS 474 - Machine Problem 2

## Inheritance of Linear Data Structures

Due: 11:59 pm on Wednesday 11/5/2003

For this assignment you must work alone.

For this assignment, you must implement four linear data structure using linked lists in Smalltalk. 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 data structures and the operations to be performed.

1. a unordered sorted list
• find
• insert
• remove
• size
2. a sorted list in increasing order
• find
• insert
• remove
• size
3. a queue
• front
• insert
• remove
• size
4. a stack
• top
• insert
• remove
• size

This project must have a GUI that shows 4 different lists. The data structure with each list can vary during the execution of the program. A combo-box like element should be used to select the type of data structure associated with each list. The GUI should show the values in the data structure with the first (left-most) value being the value pointed to by the head of the list. At least the first 10 values should be shown. The remaining items should be viable using some scrollable functionality. The operations to be performed should also use a combo-box like element. The result of any operation should be displayed on the GUI.

One example of how the GUI could be constructed is shown below. Note that the example is created using JavaScript elements, so making the exact same thing in Smalltalk may not look the same.

List 1: has elements.
 Pos: 1 2 3 4 5 6 7 8 9 10 11 12 Value: 14 51 7 -2
Operation:   Result:

List 2: has elements.
 Pos: 1 2 3 4 5 6 7 8 9 10 11 12 Value: -2 7 51 14
Operation:   Result:

List 3: has elements.
 Pos: 1 2 3 4 5 6 7 8 9 10 11 12 Value: 4 5 7 6 5 2
Operation:   Result:

List 4: has elements.
 Pos: 1 2 3 4 5 6 7 8 9 10 11 12 Value: -2 7 14 51
Operation:   Result:

The following is to clarify any of the operations.

• Some operations require input. Dialog boxes should be used to prompt for any needed input.
• For the insert operation on the unordered list, insert the value at the head of the list.
• For the find operation for the unordered list and sorted list, display the position in the list of the item or -1 if the item is not in the list. The head of the list is position 1.
• For the remove operation for the unordered list and the sorted list, 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.
• The size operations are to be performed automatically and the results shown on the GUI
• Changing the data structure type via the combo-box should cause an empty list of the selected type to be created. To stop accidentally changing this value, a "comfirm" dialog box should be displayed to the user.
• The lists may have duplicate values stored in them.