Past-paper question · 2018 October-November · Paper 42 · Q6(b)

Question 6(b) 2018 · October-November · Paper 42 · 5 marks

Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Reveal official mark-scheme answer Official mark-scheme answer for 6(B)

Official answer for Question 6

Part (b)

Question 1

mark for each completed statement

Question 5

✓
PROCEDURE DeleteNode(NodeValue: STRING, ThisPointer: INTEGER, PreviousPointer: INTEGER)
✓
IF CountryList[ThisPointer].Value = NodeValue
✓
THEN
✓
CountryList[ThisPointer].Value ← ""
✓
IF ListHead = ThisPointer
✓
THEN
✓
ListHead ← CountryList[ThisPointer].Pointer
✓
ELSE
✓
CountryList[PreviousPointer].Pointer ← CountryList[ThisPointer].Pointer
✓
ENDIF
✓
CountryList[LastNode].Pointer ← ThisPointer
✓
LastNode ← ThisPointer
✓
CountryList[ThisPointer].Pointer ← −1
✓
ELSE
✓
IF CountryList[ThisPointer].Pointer <> −1
✓
THEN
✓
CALL DeleteNode(NodeValue,CountryList[ThisPointer].Pointer, ThisPointer)
✓
ELSE
✓
OUTPUT "DOES NOT EXIST"
✓
ENDIF
✓
ENDIF
✓
ENDPROCEDURE

Mark scheme 9608_w18_ms_42.pdf →

Show text version of question

Question 6

Part (b)

Question 6

A linked list abstract data type (ADT) is created. This is implemented as an array of records. The

records are of type ListElement.

An example of a record of ListElement is shown in the following table.

Data Item Value Country "Scotland" Pointer 1

Part (b)

The program stores the position of the last node in the linked list in LastNode. The last node

always has a Pointer value of -1. The position of the node at the head of the list is stored in ListHead.

After some processing, the array and variables are in the following state.

CountryList ListHead Country Pointer 1 1 "Wales" 2 LastNode 2 "Scotland" 4 3 3 -1 4 "England" 5 5 "Brazil" 6 6 "Canada" 7 7 "Mexico" 8 8 "Peru" 9 9 "China" 10 10 11 11 12 12 13 13 14 14 15 15 3

Question 15

A
recursive algorithm searches the list for a value, deletes that value, and updates the

required pointers. When a node value is deleted, it is set to empty "" and the node is added to the end of the list.

A
node value is deleted using the pseudocode statement

CALL DeleteNode("England", 1, 0)

Complete the following pseudocode to implement the DeleteNode procedure.

PROCEDURE DeleteNode(NodeValue: STRING, ThisPointer : INTEGER, PreviousPointer : INTEGER)

IF CountryList[ThisPointer].Value = NodeValue

THEN

CountryList[ThisPointer].Value ""

IF ListHead = …………………………………………………………………………………………

THEN

ListHead ……………………………………………………………………………………………………………………………………………………………

ELSE

CountryList[PreviousPointer].Pointer CountryList[ThisPointer].Pointer

ENDIF

CountryList[LastNode].Pointer ……………………………………………………………………………………………………………

LastNode ThisPointer

……………………………………………………………………………………………………………………………………………………………………………………………………

ELSE

IF CountryList[ThisPointer].Pointer <> -1

THEN

CALL DeleteNode(NodeValue, ………………………………………………………………………………………………………………, ThisPointer)

ELSE

OUTPUT "DOES NOT EXIST"

ENDIF

ENDIF

ENDPROCEDURE

[5]

Question 16

reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Topic relevance

Why this question appears here

98% assigned-topic match · Computational thinking and problem-solving › Recursion

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_w18_qp_42.pdf

Keep practising this topic