A linked list stores positive integer data in a 2D array. The first dimension of the array stores the integer data. The second dimension of the array stores the pointer to the next node in the linked list. A linked list node with no data is initialised with the integer -1 . These nodes are linked together as an empty list. A pointer of -1 identifies that node as the last node. The linked list can store 20 nodes. The global 2D array LinkedList stores the linked list. LinkedList is initialised as an empty list. The data in each node is initialised to -1. Each node's pointer stores the index of the next node. The last node stores the pointer value -1 , which indicates it is the last node. The global variable FirstEmpty stores the index of the first element in the empty list. This is the first node in the empty linked list when it is initialised, which is index 0. The global variable Firstnode stores the index of the first element in the linked list. There is no data in the linked list when it is initialised, so FirstNode is initialised to -1 . This diagram shows the content of the initialised array. FirstEmpty = 0 FirstNode = -1 The procedure RemoveData () removes a node from the linked list. The procedure takes the data item to be removed from the linked list as a parameter. The procedure checks each node in the linked list, starting with the node FirstNode, until it finds the node to be removed. This node is added to the empty list, and pointers are changed as appropriate. The procedure only removes the first occurrence of the parameter. Assume that the data item being removed is in the linked list. (i) Write program code for RemoveData (). Save your program. Copy and paste the program code into part 3(d)(i) in the evidence document. (ii) Amend the main program to: - call RemoveData () with the parameter 5 - output the word "After" - call OutputLinkedList(). Save your program. Copy and paste the program code into part 3(d)(ii) in the evidence document. (iii) Test your program with both sets of given test data: Test data set 1: $$\(\quad 5 \quad 6 \quad 8 \quad 9 \quad 5\)$$ Test data set 2: $$\(\begin{array}{llllll}10 & 7 & 8 & 5 & 6\end{array}\)$$ Take a screenshot of each output. Save your program. Copy and paste the screenshot(s) into part 3(d)(iii) in the evidence document.
Exam No:9618_w24_qp_43 Year:2024 Question No:3(d)
Answer:





Knowledge points:
19.1 Algorithms
20.1 Programming Paradigms
Solution:
Download APP for more features
1. Tons of answers.
2. Smarter Al tools enhance your learning journey.
IOS
Download
Download
Android
Download
Download
Google Play
Download
Download