Practice
Add a Node at the End of a Linked List
2026/May/June·Variant 2·Q3·[12 marks]
HARDLinked Lists
A linked list of integers is stored in a 2D array LinkedList. Column 0 is the data; column 1 is the next-node index. A pointer of -1 marks the end of a chain. Unused slots form a separate empty list.
StartLinkedList points at the first used node. StartEmptyList points at the first unused node.
Write procedure AddItem(Value) that:
- takes the next free node from the empty list
- stores
Valuein it and links it at the end of the used list - outputs
List is fullwithout changing anything ifStartEmptyList = -1
The program already stores 12 → 18 → 25. It then inserts the given values and prints the final list.
Input: Number of values to insert, then each integer.
Output: The final list, one value per line (plus List is full for any rejected insert).
Example:
Input: 1
40
Output: 12
18
25
40
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Single append
Inputs: 1, 40
Expected: 12
18
25
40
Test 2: Two appends
Inputs: 2, 7, 9
Expected: 12
18
25
7
9