9618/43

Computer Science 9618/43May/June 2021

Cambridge A-Level · Practical · worked solutions for every part, with the mark scheme

3
questions
75
marks
150
minutes

Topics Programming Paradigms (Procedural and Object-oriented) · Algorithms and Abstract Data Types · File Processing and Exception Handling

Q1Programming Paradigms (Procedural and Object-oriented)Algorithms and Abstract Data TypesFree sample

An unordered linked list uses a 1D array to store the data.

Each item in the linked list is of a record type, node, with a field data and a field nextNode.

The current contents of the linked list are:

(a)

The following is pseudocode for the record type node.

TYPE node
    DECLARE data : INTEGER
    DECLARE nextNode : INTEGER
ENDTYPE

Write program code to declare the record type node.

Save your program as question1.

Copy and paste the program code into part 1(a) in the evidence document.

2M
(b)

Write program code for the main program.

Declare a 1D array of type node with the identifier linkedList, and initialise it with the data shown in the table on page 2. Declare the pointers.

Save your program.

Copy and paste the program code into part 1(b) in the evidence document.

4M
(c)

The procedure outputNodes() takes the array and startPointer as parameters. The procedure outputs the data from the linked list by following the nextNode values.

(i)

Write program code for the procedure outputNodes().

Save your program.

Copy and paste the program code into part 1(c)(i) in the evidence document.

6M
(ii)

Edit the main program to call the procedure outputNodes().

Take a screenshot to show the output of the procedure outputNodes().

Save your program.

Copy and paste the screenshot into part 1(c)(ii) in the evidence document.

1M
(d)

The function, addNode(), takes the linked list and pointers as parameters, then takes as input the data to be added to the end of the linkedList.

The function adds the node in the next available space, updates the pointers and returns True. If there are no empty nodes, it returns False.

(i)

Write program code for the function addNode().

Save your program.

Copy and paste the program code into part 1(d)(i) in the evidence document.

7M
(ii)

Edit the main program to:

  • call addNode()
  • output an appropriate message depending on the result returned from addNode()
  • call outputNodes() twice; once before calling addNode() and once after calling addNode().

Save your program.

Copy and paste the program code into part 1(d)(ii) in the evidence document.

3M
(iii)

Test your program by inputting the data value 5 and take a screenshot to show the output.

Save your program.

Copy and paste the screenshot into part 1(d)(iii) in the evidence document.

1M

The rest of this paper

2 more questions
  • Q2Programming Paradigms (Procedural and Object-oriented) · Algorithms and Abstract Data Types20M
  • Q3Programming Paradigms (Procedural and Object-oriented) · File Processing and Exception Handling31M
Loading the full paper…