13.1· 10 questions · 71 marks · 85 min · 2021–2023· Structured questions
Every Cambridge A Level Computer Science Paper 3 question on user-defined data types, laid out as 10 A4 pages with the mark scheme below. Nothing is left out. Free to read, no account.
1 / 10
2 / 10
3 / 10
4 / 10
10 / 10Answers below. Sit the paper first if you are practising.
Pastlit
Computer Science 9618 · User-defined data types — Paper 3
A Level · topical answer key — answer key (teacher use)
Question
Answer
Marks
8
8
8
4
4
9
8
10
8
4| Question | Answer | Marks | From |
|---|---|---|---|
| 1 | see sheet | 8 | 9618/31 May/June 2021 |
| 2 | see sheet | 8 | 9618/32 May/June 2021 |
| 3 | see sheet | 8 | 9618/33 May/June 2021 |
| 4 | see sheet | 4 | 9618/31 Oct/Nov 2021 |
| 5 | see sheet | 4 | 9618/32 Oct/Nov 2021 |
| 6 | see sheet | 9 | 9618/32 May/June 2022 |
| 7 | see sheet | 8 | 9618/31 Oct/Nov 2022 |
| 8 | see sheet | 10 | 9618/32 Oct/Nov 2022 |
| 9 | see sheet | 8 | 9618/33 Oct/Nov 2022 |
| 10 | see sheet | 4 | 9618/31 May/June 2023 |
2 (a) Describe the purpose of a user-defined data type. … … … … … [2] (b) Define, using pseudocode, the following enumerated data types: (i) SchoolDay to hold data about the days students are usually in school. … … [1] (ii) WeekEnd to hold data about the days that are not school days. … … [1] (c) Define, using pseudocode, the composite data type ClubMeet. This will hold data about club members that includes: • first name and last name • the two days they attend: ○ one on a school day ○ one not on a school day. Use the enumerated types you created in part (b). … … … … … … … … [4]
8 marks
Mark scheme: 2(a) One mark for each correct marking point (Max 2) 2 • To create a new data type (from existing data types) • To allow data types not available in a programming language to be constructed // To extend the flexibility of the programming language 2(b)(i) TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, 1 Friday) 2(b)(ii) TYPE WeekEnd = (Saturday, Sunday) 1 2(c) One mark for each marking point (Max 4) 4 • TYPE ClubMeet and ENDTYPE correct • DECLARE FirstName and DECLARE LastName included with correct data types • DECLARE Schoolday included with correct data types from part 2(b)(i) • DECLARE Weekend included with correct data types from part 2(b)(ii) Example answer TYPE ClubMeet DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Schoolday : SchoolDay DECLARE Weekend : WeekEnd ENDTYPE
2 (a) Describe the purpose of a user-defined data type. … … … … … [2] (b) Define, using pseudocode, the following enumerated data types: (i) SchoolDay to hold data about the days students are usually in school. … … [1] (ii) WeekEnd to hold data about the days that are not school days. … … [1] (c) Define, using pseudocode, the composite data type ClubMeet. This will hold data about club members that includes: • first name and last name • the two days they attend: ○ one on a school day ○ one not on a school day. Use the enumerated types you created in part (b). … … … … … … … … [4]
8 marks
Mark scheme: 2(a) One mark for each correct marking point (Max 2) 2 • To create a new data type (from existing data types) • To allow data types not available in a programming language to be constructed // To extend the flexibility of the programming language 2(b)(i) TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, 1 Friday) 2(b)(ii) TYPE WeekEnd = (Saturday, Sunday) 1 2(c) One mark for each marking point (Max 4) 4 • TYPE ClubMeet and ENDTYPE correct • DECLARE FirstName and DECLARE LastName included with correct data types • DECLARE Schoolday included with correct data types from part 2(b)(i) • DECLARE Weekend included with correct data types from part 2(b)(ii) Example answer TYPE ClubMeet DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Schoolday : SchoolDay DECLARE Weekend : WeekEnd ENDTYPE
2 (a) Describe the purpose of a user-defined data type. … … … … … [2] (b) Define, using pseudocode, the following enumerated data types: (i) SchoolDay to hold data about the days students are usually in school. … … [1] (ii) WeekEnd to hold data about the days that are not school days. … … [1] (c) Define, using pseudocode, the composite data type ClubMeet. This will hold data about club members that includes: • first name and last name • the two days they attend: ○ one on a school day ○ one not on a school day. Use the enumerated types you created in part (b). … … … … … … … … [4]
8 marks
Mark scheme: 2(a) One mark for each correct marking point (Max 2) 2 • To create a new data type (from existing data types) • To allow data types not available in a programming language to be constructed // To extend the flexibility of the programming language 2(b)(i) TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, 1 Friday) 2(b)(ii) TYPE WeekEnd = (Saturday, Sunday) 1 2(c) One mark for each marking point (Max 4) 4 • TYPE ClubMeet and ENDTYPE correct • DECLARE FirstName and DECLARE LastName included with correct data types • DECLARE Schoolday included with correct data types from part 2(b)(i) • DECLARE Weekend included with correct data types from part 2(b)(ii) Example answer TYPE ClubMeet DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Schoolday : SchoolDay DECLARE Weekend : WeekEnd ENDTYPE
3 Enumerated and pointer are two non-composite data types. (a) Write pseudocode to create an enumerated type called Parts to include these parts sold in a computer shop: Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse … … … [2] (b) Write pseudocode to create a pointer type called SelectParts that will reference the memory location in which the current part name is stored. … … … [2]
4 marks
Mark scheme: 3(a) One mark for each marking point (Max 2) 2 • TYPE Parts = • (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse) Complete answer TYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse) 3(b) One mark for each marking point (Max 2) 2 • TYPE SelectParts = ^ • correct data type chosen Parts Complete answer TYPE SelectParts = ^Parts
3 Enumerated and pointer are two non-composite data types. (a) Write pseudocode to create an enumerated type called Parts to include these parts sold in a computer shop: Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse … … … [2] (b) Write pseudocode to create a pointer type called SelectParts that will reference the memory location in which the current part name is stored. … … … [2]
4 marks
Mark scheme: 3(a) One mark for each marking point (Max 2) 2 • TYPE Parts = • (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse) Complete answer TYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse) 3(b) One mark for each marking point (Max 2) 2 • TYPE SelectParts = ^ • correct data type chosen Parts Complete answer TYPE SelectParts = ^Parts
1 Data types can be defined using pseudocode. The data type, BuildingRecord, is defined in pseudocode as: TYPE BuildingRecord DECLARE BuildingID : INTEGER DECLARE BuildingGroup : STRING DECLARE OwnerName : STRING DECLARE BuildingAddress : STRING DECLARE DateLastSold : DATE DECLARE PriceLastSold : REAL ENDTYPE A variable, BuildingRegister, is declared in pseudocode as: DECLARE BuildingRegister : BuildingRecord (a) Write pseudocode statements to assign: • 1067 to the BuildingID of BuildingRegister • house to the BuildingGroup of BuildingRegister … … … … [2] (b) The type definition for BuildingRecord is changed. The data type for BuildingGroup is changed to an enumerated type, BuildingType, with values of house, bungalow, apartment and farm. (i) Write the type declaration for BuildingType in pseudocode. … … … … [2] (ii) Write the new declaration for BuildingGroup in pseudocode. … … [1] (iii) Write the new pseudocode statement to assign house to BuildingGroup of BuildingRegister. … … [1] (c) The program is to be rewritten using Object-Oriented Programming (OOP). The data type BuildingRecord is to be changed to a class, BuildingClass. The properties for BuildingClass are BuildingID, BuildingGroup, OwnerName, BuildingAddress, DateLastSold and PriceLastSold. All the properties are set to PRIVATE, for example: PRIVATE PriceLastSold : REAL (i) Write the declaration in pseudocode for OwnerName as PRIVATE. … … [1] (ii) Explain why the properties have been set to PRIVATE. … … … … [2]
9 marks
Mark scheme: 1(a) BuildingRegister.BuildingGroup "house" 1(b)(i) One mark: TYPE BuildingType = One mark: (house, bungalow, apartment, farm) TYPE BuildingType = (house, bungalow, apartment, farm) 2 1(b)(ii) DECLARE BuildingGroup : BuildingType 1 1(b)(iii) BuildingRegister.BuildingGroup house 1 1(c)(i) PRIVATE OwnerName : STRING 1 1(c)(ii) To ensure that attributes can only be accessed by the class’s own methods To enforce encapsulation // ensure they are hidden 2
3 (a) State what is meant by the term enumerated data type. … … [1] (b) State what is meant by the term pointer data type. … … [1] (c) The months of the year are: January, February, March, April, May, June, July, August, September, October, November and December. Write the pseudocode statement to define the data type Quarter1, to hold the names of the first three months of a year. … … … … [2] (d) The composite data type Pet is used to store data about the various pets of a group of students. It uses these fields: Field name Data type PetName String AnimalType String PetAge Integer PetGender Char OwnerName String (i) Write the pseudocode statement to set up a variable for one record of the composite data type Pet. … … [1] (ii) Write pseudocode to store the details of the following pet, in the variable you set up in part (d)(i). PetName AnimalType PetAge PetGender OwnerName Tibbles Cat 8 M Jasmine Smith … … … … … … [3]
8 marks
Mark scheme: 3(a) A (user-defined non-composite) data type with an ordered list of possible values. 1 3(b) A user-defined non-composite data type used to reference a memory location. 1 3(c) Marks as shown in the square brackets: 2 TYPE Quarter1 = (January, February, March) TYPE Quarter1 = [1] (January, February, March) [1] 3(d)(i) DECLARE Pet1 : Pet 1 3(d)(ii) One mark for each point: 3 • Correct assignment of all string data values • Correct assignment of char data value • Correct assignment of integer data value Example answer: Pet1.PetName "Tibbles" Pet1.AnimalType "Cat" Pet1.PetAge 8 Pet1.PetGender 'M' Pet1.OwnerName "Jasmine Smith"
4 A program to manage regular flight details at an airport requires some user-defined data types. (a) Write pseudocode statements to declare the enumerated data type Aircraft to hold data about the types of aircraft used for a flight. These types of aircraft are: C300, C350, D242, E757, X380. … … … … [2] (b) Write pseudocode statements to declare the composite data type Flight to hold data about flights to a specific destination. These include: • flight number, which could be any combination of letters and numbers • destination • date of departure • type of aircraft used. Use the enumerated data type you created in part (a). … … … … … … … … [4] (c) (i) Write the pseudocode statement to set up a variable for one record of the composite data type Flight. … … [1] (ii) Write pseudocode to store the details of the following flight in the variable you set up in part (c)(i). Field Data flight number XA782 destination Cambridge date of departure 12/12/2022 type of aircraft used C350 Use the field names you created in part (b). … … … … … … [3]
10 marks
Mark scheme: 4(a) Marks as shown in the square brackets: 2 TYPE Aircraft = (C300, C350, D242, E757, X380) TYPE Aircraft = [1] (C300, C350, D242, E757, X380) [1] 4(b) One mark for each point (Max 4) 4 • TYPE Flight and ENDTYPE correct • DECLARE FlightNumber and DECLARE Destination as STRING • DECLARE DepartureDate as DATE • DECLARE AircraftType as Aircraft (correct data type from part 4(a)) Example answer: TYPE Flight DECLARE FlightNumber : STRING DECLARE Destination : STRING DECLARE DepartureDate : DATE DECLARE AircraftType : Aircraft ENDTYPE 4(c)(i) Example answer: 1 DECLARE Flight1 : Flight 4(c)(ii) One mark for each point (Max 3) 3 • Correct assignments of both string data values • Correct assignments of date data value • Correct assignments of enumerated data value Example answer: Flight1.FlightNumber "XA782" Flight1.Destination "Cambridge" Flight1.DepartureDate 12/12/2022 Flight1.AircraftType C350
3 (a) State what is meant by the term enumerated data type. … … [1] (b) State what is meant by the term pointer data type. … … [1] (c) The months of the year are: January, February, March, April, May, June, July, August, September, October, November and December. Write the pseudocode statement to define the data type Quarter1, to hold the names of the first three months of a year. … … … … [2] (d) The composite data type Pet is used to store data about the various pets of a group of students. It uses these fields: Field name Data type PetName String AnimalType String PetAge Integer PetGender Char OwnerName String (i) Write the pseudocode statement to set up a variable for one record of the composite data type Pet. … … [1] (ii) Write pseudocode to store the details of the following pet, in the variable you set up in part (d)(i). PetName AnimalType PetAge PetGender OwnerName Tibbles Cat 8 M Jasmine Smith … … … … … … [3]
8 marks
Mark scheme: 3(a) A (user-defined non-composite) data type with an ordered list of possible values. 1 3(b) A user-defined non-composite data type used to reference a memory location. 1 3(c) Marks as shown in the square brackets: 2 TYPE Quarter1 = (January, February, March) TYPE Quarter1 = [1] (January, February, March) [1] 3(d)(i) DECLARE Pet1 : Pet 1 3(d)(ii) One mark for each point: 3 • Correct assignment of all string data values • Correct assignment of char data value • Correct assignment of integer data value Example answer: Pet1.PetName "Tibbles" Pet1.AnimalType "Cat" Pet1.PetAge 8 Pet1.PetGender 'M' Pet1.OwnerName "Jasmine Smith"
4 Two descriptions of user-defined data types are given. Give appropriate type declaration statements for each, including appropriate names. (a) A data type to hold a set of prime numbers below 20. These prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19 … … … … [2] (b) A data type to point to a day in the week, for example Monday. … … … … [2]
4 marks
Mark scheme: 4(a) One mark per mark point (Max 2) 2 TYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19) Example answer TYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19) 4(b) One mark per mark point (Max 2) 2 TYPE TDayPointer = ^STRING //^DayOfWeek Example answer TYPE TDayPointer = ^STRING // ^DayOfWeek