Past-paper question · 2017 May-June · Paper 41 · Q4(c)(iv)

Question 4(c)(iv) 2017 · May-June · Paper 41 · 1 mark

Original past-paper question for 4(C)(IV)
Original past-paper question for 4(C)(IV)
Original past-paper question for 4(C)(IV)
Original past-paper question for 4(C)(IV)
Original past-paper question for 4(C)(IV)
Reveal official mark-scheme answer Official mark-scheme answer for 4(C)(IV)

Official answer for Question 4

Part (c)

(iv)

✓
•
✓
Creating instance of LinkedList assigned to contacts

Question 1

✓
Python Example
✓
contacts = LinkedList()
✓
Pascal Example
✓
var contacts : LinkedList;
✓
contacts := LinkedList.Create;
✓
VB.NET Example
✓
Dim contacts As New LinkedList
✓
9608/41
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2017
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s17_ms_41.pdf →

Show text version of question

Question 4

Part (c)

(iv)

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:
  • 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.

  • NextPointer, whose value is a

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.

(iv)

Write program code to instantiate a linked list object with the contacts identifier.

Programming language used ............................................................................................

Program code

...........................................................................................................................................

.......................................................................................................................................[1]

Topic relevance

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

Keep practising this topic