Context for question 3
A 2D array is used to store the linked list, LinkedList. The linked list stores a maximum of eight data items. Each data item is an integer.
The array elements not currently used in the linked list are stored as the empty list.
LinkedList has two pointers:
- StartLinkedList stores a pointer to the first node in the linked list
- StartEmptyList stores a pointer to the first node in the empty list.
A data value of -1 indicates there is no data in the node. A pointer of -1 indicates it is the end of the linked list, or the end of the empty list.
The linked list and pointers all have global scope.
The linked list already has the following data stored:
| array index | data | pointer |
|---|---|---|
| 0 | 9512 | 5 |
| 1 | 5541 | 3 |
| 2 | 1999 | 0 |
| 3 | 6651 | -1 |
| 4 | -1 | 6 |
| 5 | 5612 | 1 |
| 6 | -1 | -1 |
| 7 | -1 | 4 |
StartLinkedList currently stores 2. StartEmptyList currently stores 7.