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

Q11 · 9618/31/M/J/24 Q3

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

Q119618/31/M/J/24original Q3Structured · 7 marks
Question 3 from 9618/31/M/J/24

Worked solution

(a)

Write about both kinds of data type. Any three of these, but no more than two for each kind:

Non-composite types can be primitive or user-defined. [1]

Non-composite types do not refer to other data types in their definition (they contain one data type). [1]

Non-composite types can be primitive, enumerated or pointer types. (also credited, but no extra mark: any n only)

Composite types can be primitive or user-defined. [1]

Composite types refer to other data types in their definition (they contain more than one data type). (also credited, but no extra mark: any n only)

Composite types can be record, set or class types. (also credited, but no extra mark: any n only)

(b)

A record is declared between TYPE and ENDTYPE, with one DECLARE for each field.

TYPE FootballClub
    DECLARE TeamName : STRING
    DECLARE DateOfJoining : DATE
    DECLARE MainTelephone : STRING
    DECLARE ManagerName : STRING
    DECLARE NumberOfMembers : INTEGER
    DECLARE LeaguePosition : INTEGER
ENDTYPE

TYPE FootballClub and ENDTYPE written correctly [1]

First two fields declared correctly [1]

Next two fields declared correctly [1]

Last two fields declared correctly [1]

Other sensible identifiers and data types are accepted, for example the telephone number as a STRING.

KEY IDEAComposite types are built from other types; a record is declared with TYPE, one DECLARE per field, and ENDTYPE.
TOTAL 7 marks

Official mark scheme

Mark scheme for 9618/31/M/J/24 question 3
VIDEO
▶ Starts at Q3 (14:51)

Starts at Q3 (14:51) · by Pseudocode Pro. 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.