Question 4(c)(ii) 2017 · May-June · Paper 41 · 2 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (c)
(ii)
- 1 (accept NULL)
Question 2
Show text version of question
Question 4
Part (c)
(ii)
Question 4
An ordered linked list Abstract Data Type (ADT) has these associated operations:
- create list
- add item to list
- output list to console
The ADT is to be implemented using object-oriented programming as a linked list of nodes.
Each node consists of data and a pointer. The identifier table for the LinkedList class is:
Identifier Data type Description HeadPointer INTEGER Pointer to the first node in the ordered list. FreeListPointer INTEGER Pointer to the first node in the free list. NodeArray ARRAY[0 : 7] OF Node 1D array stores the nodes that make the ordered linked list. The unused nodes are linked together into a free list. Constructor() Constructor instantiates an object of LinkedList class, initialises HeadPointer to be a null pointer and links all nodes to form the free list. FindInsertionPoint() Procedure that takes the new data item as the parameter NewData and returns two parameters:
- PreviousPointer, whose value is:
- NextPointer, whose value is a
either pointer to node before the insertion point or the null pointer if the new node is to be inserted at the beginning of the list.
pointer to node after the insertion point. AddToList(NewString) Procedure that takes as a parameter a unique string and links it into the correct position in the ordered list. OutputListToConsole() Procedure to output all the data from the list pointed to by HeadPointer.
The following diagram shows an example of a linked list object. This example list consists of three nodes, linked in alphabetical order of the data strings. The unused nodes are linked to form a free list.
HeadPointer Berlin London Paris Ø node node node
FreeListPointer Ø node node node node
The symbol O represents a null pointer.
(ii)
Give an appropriate value to represent the null pointer for this design. Justify your
answer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
Why this question appears here
98% assigned-topic match · Further programming › Programming paradigms
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_s17_qp_41.pdf
