Lab 13
Linked List - Charades
Check in with your TA using this form form .
Scenario: In today's lab we will look at how to keep track of movie names, to use in a game of charades.
We have provided the code that prompts the user for movie names and stores them in a linked list. We signal end of input by typing in -1.
The task for today's lab
-----------------------------
1. Find out how many nodes are in the list. (1 point)
2. Choose a node at random from the list, and print it out. The node chosen should not be the last one. (1 point)
3. Delete that chosen node from the list, so it can't be reused. Remember you are not required to handle the case of deleting the last node as it will never be chosen in step 2. (1 point)
Completing the program would give the following output.
Linked list program, prepending to head of the list.
Enter as many movie names as you would like (minimum three), followed by -1:
Zootopia
Deadpool
The Revenant
Batman v Superman: Dawn of Justice
-1
List contains:
Batman v Superman: Dawn of Justice
The Revenant
Deadpool
Zootopia
*****Stage 1 Output******
Number of nodes in the linked list: 4
*****Stage 2 Output******
Random number chosen: 1
Randomly chosen node contains: The Revenant
*****Stage 3 Output******
After Deletion....
List contains:
Batman v Superman: Dawn of Justice
Deadpool
Zootopia
Ending Linked List program. Exiting ...