9618/31/M/J/24 question 3: worked solution (May/June 2024, paper 31)

Show as plain text

Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3. Q11 9618/31/M/J/24 original Q3 Structured · 7 marks 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 IDEA Composite types are built from other types; a record is declared with TYPE, one DECLARE per field, and ENDTYPE. TOTAL 7 marks Official mark scheme VIDEO ▶ Starts at Q3 (14:51) Starts at Q3 (14:51) · by Pseudocode Pro. Tap the picture to open it on YouTube.