Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types

Q3 · 9618/31/M/J/22 Q1

Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3.

Q39618/31/M/J/22original Q1Structured · 8 marks
Question 1 from 9618/31/M/J/22

Worked solution

(a)

LibraryBook.Title ← "A Level Computer Science"
LibraryBook.Fiction ← FALSE

Title assigned using LibraryBook.Title and the text in quotes [1]

Fiction assigned FALSE using LibraryBook.Fiction [1]

(b)(i)

Use a range type for the field.

DECLARE NumberOfCopies : 1 .. 10

Range 1 .. 10 used in place of INTEGER [1]

(b)(ii)

One book can have many accession numbers, so use an array whose size is NumberOfCopies.

DECLARE AccessionNumber : ARRAY[1:NumberOfCopies] OF INTEGER

Array declared with the name AccessionNumber and bounds 1 to NumberOfCopies [1]

Array elements are of type INTEGER [1]

(c)

A user-defined composite data type is:

A data type made by the programmer, not a built-in (primitive) type [1]

It refers to at least one other data type, and these can be primitive or user-defined [1]

A correct example of another composite type, such as a class (object) or a set [1]

KEY IDEAA composite type is built by the programmer from other types, such as a record, class or set.
TOTAL 8 marks

Official mark scheme

Mark scheme for 9618/31/M/J/22 question 1
VIDEO
▶ Whole paper

Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.