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

Question 4(b) 2017 · May-June · Paper 41 · 5 marks

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

Official answer for Question 4

Part (b)

✓
mark as follows:

Question 5

✓
•
✓
Class heading and ending
✓
•
✓
Constructor heading and ending
✓
•
✓
Parameters in constructor heading
✓
•
✓
Declaration of (private) attributes : Pointer, Data
✓
•
✓
Assignment of parameters to Pointer and Data
✓
Python Example
✓
class Node:

Question 1

✓
def __init__(self, D, P):
✓
1 + 1
✓
self.__Data = D

Question 1

✓
self.__Pointer = P

Question 1

✓
return
✓
Example Pascal
✓
type
✓
Node = class

Question 1

✓
private

Question 1

✓
Data : String;
✓
Pointer : Integer;
✓
public
✓
constructor Create(D : string; P : integer);
✓
procedure SetPointer(P : Integer);
✓
procedure SetData(D : String);
✓
function GetData() : String;
✓
function GetPointer() : Integer;
✓
end;
✓
constructor Node.Create(D : string; P : integer);
✓
1+1
✓
begin
✓
Data := D;
✓
Pointer := P;

Question 1

✓
end;
✓
Example VB.NET
✓
Class Node

Question 1

✓
Private Data As String
✓
Private Pointer As Integer

Question 1

✓
Public Sub New(ByVal D As String, ByVal P As Integer)
✓
1+1
✓
Data = D
✓
Pointer = P

Question 1

✓
End Sub
✓
End Class

Mark scheme 9608_s17_ms_41.pdf →

Show text version of question

Question 4

Part (b)

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.

Part (b)

The design for the Node class consists of:

  • attributes
  • Data : STRING Pointer : INTEGER

  • methods

CreateNode(Data, Pointer) SetData(Data) SetPointer(Pointer) GetData() RETURNS STRING GetPointer() RETURNS INTEGER

The constructor method sets the attributes to the initial values that are passed as parameters.

Write program code for:

  • the Node class declaration
  • the constructor.

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

Program code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[5]

Question 10

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