User Tools

Site Tools


haas:fall2012:common:data-p03-20121024130000

Using a Doubly Linked List, reimplement the menu-based program we did using singly-linked lists.

  • Split up the code to have separate functions which do the following:
    • main() - central program, provides a menu to launch into each operation.
    • append() - passing the appropriate values, append a new node after a given node on a list.
    • insert() - passing the appropriate values, insert a new node before a given node on a list.
    • remove() - passing the appropriate values, remove indicated node from a list and deallocate it.
    • displayfwd() - passing a list, display the nodes in the list.
    • displayrev() - passing a list, display the nodes in the list in reverse.

This is essentially testing your ability to organize code into functions, and to call those functions.

Having a menu-driven interface (just text will do), will enable more selective testing of your linked list's functionality. Note that when the program is run, the menu should be the very first thing the user sees, and no list should be in existence until (and if) a user decides to do so. The menu should also have some sort of exit option.

To submit, place any and all related source files in your repository under the following directory: ~/src/data/submit/p03/ (creating any missing directories as needed) and add/commit/push it to your personal repository.

I plan to wander around and check off with each person as part of this project's evaluation, so be prepared to show me your code, perform a sample run, and potentially answer any questions I may have about the code.

Points I will look to evaluate:

  • Does it compile clean?
  • Does it run (any combination of actions) without error or problem?
  • Does it have and use functions for the various doubly linked list operations?
  • Does the menu allow full and operational and correct control over all actions of the doubly linked list?

Potential sample output of this desired program:

lab46:~/src/data/submit/p03$ ./linkedlistmenu

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 0
NULL

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 2
Empty List Detected!
Enter Value for new node: 7

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 2

(0) 7 -> NULL
Enter position to Append after (0-0): 0
Enter Value for new node: 9

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 3
(0) 7 -> (1) 9 -> NULL
Enter position to Insert before (0-1): 0
Enter value for new node: 2

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 0
(0) 2 -> (1) 7 -> (2) 9 -> NULL

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 1
(2) 9 -> (1) 7 -> (0) 2 -> NULL

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 4
(0) 2 -> (1) 7 -> (2) 9 -> NULL
Enter position of node to remove: 0

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 0
(0) 7 -> (1) 9 -> NULL

Linked List Operations
----------------------
0. Display the list forward
1. Display the list backward
2. Append a new node
3. Insert a new node
4. Remove a node
9. Quit

Enter Selection: 9
lab46:~/src/data/submit/p03$ 
haas/fall2012/common/data-p03-20121024130000.txt · Last modified: 2012/10/22 11:20 by 127.0.0.1