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 InsertData () takes five positive integers as input from the user and inserts these into the linked list. Each data item is inserted at the front of the linked list. The table shows the steps to follow depending on the state of the linked list: Any node that is at the end of the linked list has a pointer of -1 . Write program code for InsertData(). Save your program. Copy and paste the program code into part 3(b) in the evidence document. 14
Exam No:9618_w24_qp_43 Year:2024 Question No:3(b)
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