13.1 User-defined Data Types
A Level · 30 questions found
What this topic covers
Section titled “What this topic covers”- Why user-defined types are necessary
- Non-composite types: enumerated, pointer
- Composite types: set, record, class/object
- Choose and design an appropriate user-defined type for a given problem
Past paper questions
Section titled “Past paper questions”The composite record data type, ClubMember, is defined in pseudocode as:
TYPE ClubMember DECLARE Code : INTEGER DECLARE LastName : STRING DECLARE FirstName : STRING DECLARE Telephone : STRING DECLARE JoinDate : DATE DECLARE Fees : REAL DECLARE FeesPaid : BOOLEAN ENDTYPE
(a) (i) Write the pseudocode statement to set up a variable for one record of the composite data type, ClubMember. 1 mark
(ii) Write the pseudocode statements to assign the following values to the variable set up in part (a)(i): 2 marks
984632 to Code
TRUE to FeesPaid
(b) An enumerated data type, Activity, is required, so that a new field, Choice, can be added to the composite data type, ClubMember, to allow members to choose an activity.
(i) Write the pseudocode statement for the type declaration of Activity to hold the names of the available activities: 2 marks
Badminton, Football, Golf, Snooker, Swimming, Tennis.
(ii) Write the new pseudocode statement required to update the declaration of Choice in the definition of ClubMember. 1 mark
Show mark scheme
1(a)(i) [1 mark]
DECLARE Member1 : ClubMember
1(a)(ii) [2 marks]
One mark for each correct answer Example answer Member1.Code 984632 Member1.FeesPaid TRUE
1(b)(i) [2 marks]
One mark per mark point ( Max 2 ) MP1 TYPE Activity= MP2 (Badminton, Football, Golf, Snooker, Swimming, Tennis) Example answer TYPE Activity = (Badminton, Football, Golf, Snooker, Swimming, Tennis)
1(b)(ii) [1 mark]
DECLARE Choice : Activity
The composite data type, Car, is defined in pseudocode as:
TYPE Car DECLARE RegNumber : STRING DECLARE Make : STRING DECLARE Model : STRING DECLARE BodyStyle : STRING DECLARE Colour : STRING DECLARE IntoStock : DATE DECLARE Price : REAL ENDTYPE
(a) (i) Write the pseudocode statement to set up a variable for one record of the composite data type, Car. 1 mark
(ii) Write the pseudocode statements to assign the following values to the variable set up in part (a)(i): 2 marks
"Blue" to Colour
21/10/2025 to IntoStock
(b) The data type for BodyStyle is changed to an enumerated type, Body.
(i) Write the pseudocode statement for the type declaration of Body to hold the names of the available choices: 2 marks
Convertible, Hatchback, Saloon, SUV
(ii) Write the new pseudocode statement required to update the declaration of BodyStyle in the definition of Car. 1 mark
Show mark scheme
1(a)(i) [1 mark]
DECLARE Car1 : Car
1(a)(ii) [2 marks]
One mark for each correct answer Example answer Car1.Colour "Blue" Car1.IntoStock 21/10/2025
1(b)(i) [2 marks]
One mark per mark point ( Max 2 ) MP1 TYPE Body = MP2 (Convertible, Hatchback, Saloon, SUV) Example answer TYPE Body = (Convertible, Hatchback, Saloon, SUV) DECLARE BodyStyle : Body
1(b)(ii) [1 mark]
(a) An enumerated data type, Spectrum, is required to hold the names of colours.
(i) Write the pseudocode statement for the type declaration of Spectrum to hold the names of the colours available: 2 marks
Red, Orange, Yellow, Green, Blue, Indigo, Violet.
(ii) Identify two characteristics of the list of values given in an enumerated data type declaration. 2 marks
1
2
(b) ColourData is a composite data type to store definitions of colours. 4 marks
Write pseudocode statements to declare ColourData to hold the following fields:
| Field | Example data |
|---|---|
| ColourCode | XYZ12345 |
| Colour | Red |
| Wavelength | 650 |
| Frequency | 4.62 |
| PrimaryColour | Yes |
Use the most appropriate data type in each case, including the enumerated data type Spectrum from part a(i).
Show mark scheme
1(a)(i) [2 marks]
One mark per mark point ( Max 2 ) MP1 TYPE Spectrum
MP2 (Red, Orange, Yellow, Green, Blue, Indigo, Violet) Example answer TYPE Spectrum = (Red, Orange, Yellow, Green, Blue, Indigo, Violet)
1(a)(ii) [2 marks]
One mark per mark point ( Max 2 ) MP1 the list is ordered/ordinal MP2 the list contains all possible values MP3 no duplicate values in list MP4 all values are the same data type
1(b) [4 marks]
One mark for and correct TYPE ColourData ENDTYPE One mark for correct use of DECLARE in all declarations One mark for correct use of in declaration Spectrum One mark for remaining four declarations correct (STRING, INTEGER, REAL, BOOLEAN) Example answer TYPE ColourData DECLARE ColourCode : STRING DECLARE Colour : Spectrum DECLARE Wavelength : INTEGER DECLARE Frequency : REAL DECLARE PrimaryColour : BOOLEAN ENDTYPE
A programmer is writing a program to manage bookings for a small taxi company. The programmer requires some user-defined data types.
(a) Write a pseudocode statement to declare the enumerated data type, Vehicle, to hold the identity code of each of the company’s taxis: 2 marks
M100, M230, T101, T102, T120, T150
(b) Write pseudocode statements to declare the composite data type, Booking, to hold data about taxi bookings. The data required includes: 4 marks
booking number (any combination of letters and numbers)
destination
client name
client telephone number
date of departure
address for pick-up
the identity code of the taxi used.
Use the most appropriate data type in each case, including the enumerated data type from part (a).
Show mark scheme
1(a) [2 marks]
One mark per mark point MP1 TYPE Vehicle = MP2 (M100, M230, T101, T102, T120, T150) Example answer: TYPE Vehicle = (M100, M230, T101, T102, T120, T150)
1(b) [4 marks]
One mark per mark point MP1 and correct TYPE Booking ENDTYPE MP2 Declare used correctly for every field in the response MP3 Any four fields correct MP4 Remaining fields correct Example answer: TYPE Booking DECLARE BookingNumber : STRING DECLARE Destination : STRING DECLARE ClientName : STRING DECLARE ClientTelephone : STRING DECLARE DateOfDeparture : DATE DECLARE PickupAddress : STRING DECLARE TaxiUsed : Vehicle ENDTYPE
Data types can be defined using pseudocode.
The composite record data type, Departure, is used to represent flights from Cambridge Airport and is defined in pseudocode as:
TYPE Departure DECLARE FlightNumber : STRING DECLARE Destination : STRING DECLARE FlightDate : DATE DECLARE Gate : STRING DECLARE Airline : STRING ENDTYPE
A variable, Flight1, is declared in pseudocode as:
DECLARE Flight1 : Departure
(a) Write pseudocode to store the following details to Flight1: 3 marks
| Field | Data |
|---|---|
| FlightNumber | SB2789 |
| Destination | Dublin |
| FlightDate | 30/07/2025 |
| Gate | N03 |
| Airline | Cambridge Airways |
(b) The data type for Gate is changed to an enumerated data type, GateID.
(i) Write a pseudocode statement to declare GateID to hold the identity codes for the airport gates: 2 marks
N01, N02, N03, W01, W02, W03, W04
(ii) Write the new pseudocode statement required to replace the declaration of Gate in Departure. 1 mark
Show mark scheme
1(a) [3 marks]
One mark for each mark point MP1 Use of correct variable with given field names Flight1 MP2 Correct assignments of four string data values MP3 Correct assignment of date data value Example answer Flight1.FlightNumber "SB2789" Flight1.Destination "Dublin" Flight1.FlightDate 30/07/2025 Flight1.Gate "N03" Flight1.Airline "Cambridge Airways"
1(b)(i) [2 marks]
One mark per mark point MP1 TYPE GateID = MP2 (N01, N02, N03, W01, W02, W03, W04) Example answer TYPE GateID = (N01, N02, N03, W01, W02, W03, W04) DECLARE Gate : GateID
A programmer is writing a program to manage a video library. They require a user-defined data type.
(a) Write pseudocode statements to declare the composite data type VideoLibrary to hold data about each video in the collection. This data includes: 4 marks
identity code (any combination of letters and numbers)
title
year released
date purchased
format (for example DVD, Blu-ray, 4K, MP4)
running time (minutes)
Use the most appropriate data type in each case.
(b) Identify one field in VideoLibrary that could be an efficient enumerated data type and give a reason for your choice. 2 marks
Field
Reason
Show mark scheme
1(a) [4 marks]
One mark per mark point MP1 and correct TYPE VideoLibrary ENDTYPE MP2 Declare used correctly for every field in the response MP3 All Three STRING fields correct (shaded) MP4 Remaining Three fields correct (unshaded) Example answer TYPE VideoLibrary DECLARE VideoID : STRING DECLARE Title : STRING DECLARE ReleaseYear : INTEGER DECLARE PurchaseDate : DATE DECLARE VideoFormat : STRING DECLARE RunningTime : INTEGER ENDTYPE
1(b) [2 marks]
One mark for identification of field and one mark for reason VideoFormat This field can have a fixed range of possible values
(a) Describe the user-defined data type set. 3 marks
(b) Write pseudocode statements to declare the set data type, SymbolSet, to hold the following set of mathematical operators, using the variable Operators. 4 marks
- – * / ^
Show mark scheme
6(a) [3 marks]
One mark per mark point ( Max 3 ) MP1 A set user-defined data type is a composite data type MP2 … which includes a list of unordered elements MP3 Set theory operations, such as intersection and union, can be applied to these elements MP4 A set data type includes the type of data/data type it uses as part of its definition MP5 All the elements are of the same data type.
6(b) [4 marks]
One mark for each mark point ( Max 4 ) MP1 / TYPE SymbolSet Operators = MP2 SET OF CHAR MP3 / DEFINE Operators SymbolSet MP4 ('+', '–', '', '/', '^') MP5 / : SymbolSet Operators Example answers TYPE SymbolSet = SET OF CHAR DEFINE Operators ('+', '–', '', '/', '^') : SymbolSet TYPE Operators = SET OF CHAR DEFINE SymbolSet ('+', '–', '*', '/', '^') : Operators
(a) Describe the user‑defined data type record. 3 marks
(b) A programmer defines a record, Order, to store the following data: 4 marks
account number
order number
order price
order date.
Write pseudocode statements to define this record.
Show mark scheme
3(a) [3 marks]
One mark per mark point ( Max 3 ) MP1 A user-defined record data type is a composite data type MP2 It uses other data types in its definition to form a single new data type MP3 The data types referenced may be primitive data types from a programming language or they may be other user- defined data types. MP4 Includes related items MP5 Includes a fixed number of items. TYPE Order ENDTYPE
3(b) [4 marks]
One mark for and correct DECLARE One mark for correct use of in all declarations seen One mark for the two shaded declarations One mark for the two unshaded declarations Example answer TYPE Order DECLARE AccountNumber : INTEGER DECLARE OrderNumber : INTEGER DECLARE OrderPrice : REAL DECLARE OrderDate : DATE ENDTYPE
(a) Describe the user-defined data type set. 3 marks
(b) Write pseudocode statements to declare the set data type, SymbolSet, to hold the following set of mathematical operators, using the variable Operators. 4 marks
- – * / ^
Show mark scheme
6(a) [3 marks]
One mark per mark point ( Max 3 ) MP1 A set user-defined data type is a composite data type MP2 … which includes a list of unordered elements MP3 Set theory operations, such as intersection and union, can be applied to these elements MP4 A set data type includes the type of data/data type it uses as part of its definition MP5 All the elements are of the same data type.
6(b) [4 marks]
One mark for each mark point ( Max 4 ) MP1 / TYPE SymbolSet Operators = MP2 SET OF CHAR MP3 / DEFINE Operators SymbolSet MP4 ('+', '–', '', '/', '^') MP5 / : SymbolSet Operators Example answers TYPE SymbolSet = SET OF CHAR DEFINE Operators ('+', '–', '', '/', '^') : SymbolSet TYPE Operators = SET OF CHAR DEFINE SymbolSet ('+', '–', '*', '/', '^') : Operators
(a) Explain what is meant by non-composite and composite data types. 3 marks
Show mark scheme
3(a) [3 marks]
mark per mark point ( Max 2 ) non-composite data types Non-composite data types can both be user-defined or primitive Non-composite data types do not refer to other data types in their definition / contain one data type in their definition Non-composite data types can be primitive/enumerated/pointer mark per mark point ( Max 2 ) composite data types Composite data types can be user-defined or primitive Composite data types refer to other data types in their definition/contain more than one data type in their definition Composite data types can be record/set/class
3(b) [4 marks]
mark for TYPE FootballClub and ENDTYPE correct mark for every two correct declarations Example answer TYPE FootballClub DECLARE TeamName : STRING DECLARE DateOfJoining : DATE DECLARE MainTelephone : STRING DECLARE ManagerName : STRING DECLARE NumberOfMembers : INTEGER DECLARE LeaguePosition : INTEGER ENDTYPE
(a) Explain what is meant by the term non-composite data type and give an example of a non-composite data type. 3 marks
Example
(b) Write pseudocode statements to declare the set data type EvenNumbers to hold this set of even numbers between 2 and 12: 4 marks
2, 4, 6, 8, 10, 12
Show mark scheme
3(a) [3 marks]
mark per mark point ( Max 3 ) A data type that is defined without referencing another data type. It can be a primitive data type found in a programming language or a user-defined data type. Example – enumerated data type / pointer data type / allow a correct example of an enumerated or pointer data type declaration.
3(b) [4 marks]
mark per mark point (
Max 4
)
Type statement fully correct
DEFINE EvenNumbers
Correct list of values in brackets
:
(a) Explain what is meant by non-composite and composite data types. 3 marks
Show mark scheme
3(a) [3 marks]
mark per mark point ( Max 2 ) non-composite data types Non-composite data types can both be user-defined or primitive Non-composite data types do not refer to other data types in their definition / contain one data type in their definition Non-composite data types can be primitive/enumerated/pointer mark per mark point ( Max 2 ) composite data types Composite data types can be user-defined or primitive Composite data types refer to other data types in their definition/contain more than one data type in their definition Composite data types can be record/set/class
3(b) [4 marks]
mark for TYPE FootballClub and ENDTYPE correct mark for every two correct declarations Example answer TYPE FootballClub DECLARE TeamName : STRING DECLARE DateOfJoining : DATE DECLARE MainTelephone : STRING DECLARE ManagerName : STRING DECLARE NumberOfMembers : INTEGER DECLARE LeaguePosition : INTEGER ENDTYPE
Describe what is meant by enumerated and pointer data types.
Enumerated
Pointer 4 marks
Show mark scheme
3 [4 marks]
One mark per mark point – enumerated type ( Max 2 ) MP1 A user-defined non-composite (data type) (only award once) MP2 …with a list of all possible values MP3 …that is ordered. One mark per mark point – pointer type ( Max 2 ) MP4 A user-defined non-composite (data type) (only award once) MP5 …that stores addresses/memory locations only MP6 …and indicates the type of data stored in the memory location.
Describe what is meant by composite and non‑composite data types.
Composite
Non‑composite 4 marks
Show mark scheme
2 [4 marks]
One mark per mark point – composite ( Max 2 ) MP1 A (user defined) data type that is a collection of data that can consist of multiple elements MP2 …of different or the same data types MP3 …grouped under a single identifier. One mark per mark point – non-composite ( Max 2 ) MP4 It can be defined without referencing another data type. MP5 It can be a primitive type available in a programming language, or a user- defined type.
Describe what is meant by enumerated and pointer data types.
Enumerated
Pointer 4 marks
Show mark scheme
3 [4 marks]
One mark per mark point – enumerated type ( Max 2 ) MP1 A user-defined non-composite (data type) (only award once) MP2 …with a list of all possible values MP3 …that is ordered. One mark per mark point – pointer type ( Max 2 ) MP4 A user-defined non-composite (data type) (only award once) MP5 …that stores addresses/memory locations only MP6 …and indicates the type of data stored in the memory location.
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 marks
2, 3, 5, 7, 11, 13, 17, 19
(b) A data type to point to a day in the week, for example Monday. 2 marks
Show mark scheme
4(a) [2 marks]
One mark per mark point ( Max 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) [2 marks]
One mark per mark point ( Max 2 ) TYPE TDayPointer // = ^STRING ^DayOfWeek Example answer // TYPE TDayPointer = ^STRING ^DayOfWeek
(a) Write pseudocode statements to declare the composite data type, TAppointments, to hold data about patients for a dental clinic. It will include for each patient: 4 marks
name (first name and last name)
date of birth
telephone number
date of last appointment
date of next appointment
all treatments are complete (yes or no).
(b) This pseudocode algorithm reads dental records stored in a random file using the user‑defined data type TAppointments and prints the contents of the file, one record at a time. 5 marks
Complete this file handling pseudocode:
DECLARE DentalRecord : ARRAY[1:250] OF TAppointments
DECLARE DentalFile : STRING
DECLARE Count : INTEGER
DentalFile "DentalFile.dat"
OUTPUT "The file ", DentalFile, " contains these records:"
OPENFILE
______ 1
REPEAT
SEEK DentalFile, Count
OUTPUT DentalRecord[Count]
Count Count + 1
______ (DentalFile)
Show mark scheme
6(a) [5 marks]
One mark for and correct TYPE TAppointments ENDTYPE One mark for every two correct declarations ( Max 3 ) Example answer TYPE TAppointments DECLARE Name : STRING DECLARE DateOfBirth : DATE DECLARE Telephone : STRING DECLARE LastAppointment : DATE DECLARE NextAppointment : DATE DECLARE TreatmentsComplete : BOOLEAN ENDTYPE
6(b) [2 marks]
One mark for each correctly completed line ( Max 5 ) DECLARE DentalRecord : ARRAY[1:250] OF TAppointments DECLARE DentalFile : STRING DECLARE Count : INTEGER DentalFile "DentalFile.dat" OUTPUT "The file ", DentalFile, " contains these records:" OPENFILE DentalFile FOR RANDOM Count 1 REPEAT SEEK DentalFile, Count GETRECORD DentalFile, DentalRecord[Count] OUTPUT DentalRecord[Count] Count Count + 1 UNTIL EOF (DentalFile) CLOSEFILE DentalFile
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 marks
2, 3, 5, 7, 11, 13, 17, 19
(b) A data type to point to a day in the week, for example Monday. 2 marks
Show mark scheme
4(a) [2 marks]
One mark per mark point ( Max 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) [2 marks]
One mark per mark point ( Max 2 ) TYPE TDayPointer // = ^STRING ^DayOfWeek Example answer // TYPE TDayPointer = ^STRING ^DayOfWeek
A business sells a single product. Customers can purchase one or more of this product.
Each sale has an ID and a quantity, for example "ABC" and 2
The business needs a program to store the data about the sales in a circular queue data structure.
(a) Write program code to declare a record structure, SaleData, to store the data about each sale. 2 marks
Save your program as Question2_J2023 .
Copy and paste the program code into part 2(a) in the evidence document.
(b) Write program code to: 4 marks
declare a global array,
CircularQueue, of 5 items to store the sale recordsdeclare the global pointers
HeadandTaildeclare the global variable
NumberOfItemsinitialise all elements of the array
CircularQueueto an empty record, where the ID is null ("") and quantity is-1initialise
Head,TailandNumberOfItemsto0
Save your program.
Copy and paste the program code into part 2(b) in the evidence document.
(c) The function Enqueue() : 6 marks
takes a new record as a parameter
inserts the record in the circular queue at the element pointed to by
Tailupdates pointers and other variables as required
returns −1 if the circular queue is full
returns
1if the record is stored successfully.
Write program code for the function Enqueue() .
Save your program.
Copy and paste the program code into part 2(c) in the evidence document.
(d) The function Dequeue() : 6 marks
returns a null or empty record if the circular queue is empty
returns the first record in the queue if the circular queue is not empty
updates pointers and other variables as required.
Write program code for the function Dequeue() .
Save your program.
Copy and paste the program code into part 2(d) in the evidence document.
(e) The procedure EnterRecord() : 5 marks
takes an ID and quantity as input and creates a sale record
uses
Enqueue()to insert the record in the circular queueoutputs
"Full"if the record was not inserted in the circular queueoutputs
"Stored"if the record was inserted in the circular queue.
Write program code for the procedure EnterRecord() .
Save your program.
Copy and paste the program code into part 2(e) in the evidence document.
(f) The following sale records need to be entered into the program:
| ID | Quantity |
|---|---|
| ADF | 10 |
| OOP | 1 |
| BXW | 5 |
| XXZ | 22 |
| HQR | 6 |
| LLP | 3 |
(i) Amend the main program to: 4 marks
use
EnterRecord()to input the six records in the tableuse
Dequeue()to remove one recordoutput either the ID and quantity of the removed record, or an error message if the circular queue is empty
use
EnterRecord()to input the record with the ID "LLP" for a second timeoutput the ID and quantity for all the records currently stored in the array
CircularQueue.
Write program code to perform these tasks.
Save your program.
Copy and paste the program code into part 2(f)(i) in the evidence document.
(ii) Test your program. 1 mark
Take a screenshot of the output.
Save your program.
Copy and paste the screenshot into part 2(f)(ii) in the evidence document.
Show mark scheme
2(a) [2 marks]
1 mark each Record declaration named SaleData // class declaration (and end) named SaleData … SaleID declared as string, Quantity as integer in record // if a class then a constructor assigning attributes SaleID and Quantity Example Program code: class SaleData{ private String SaleId; private Integer Quantity; public SaleData(String SaleIDP, Integer Quantityp){ SaleId = SaleIDP; Quantity = Quantityp; } VB.NET Structure SaleData Public SaleID As String Public Quantity As Integer End Structure Python class SaleData: def init(self, SaleIDp, Quantityp): self.SaleID = SaleIDp #string self.Quantity = Quantityp #integer
2(b)
Python CircularQueue = [] #SaleData, 5 items global NumberOfItems #int global Head #int global Tail #int #main NumberOfItems = 0 Head = 0 Tail = 0 for x in range(0, 5): CircularQueue.append((SaleData("",-1)))
2(c)
Else Tail += 1 End If NumberOfItems += 1 Return 1 End If End Function Python def Enqueue(RecordToAdd): global NumberOfItems #int global Head #int global Tail #int if(NumberOfItems == 5): return -1 else: CircularQueue[Tail] = RecordToAdd if(Tail == 4): Tail = 0 else: Tail +=1 NumberOfItems +=1 return 1
2(d)
Else Head += 1 End If End If Return RecordRemoved End Function Python def Dequeue(): global NumberOfItems #int global Head #int global Tail #int RecordRemoved = SaleData("", -1) if not(NumberOfItems == 0): RecordRemoved = CircularQueue[Head] NumberOfItems -=1 if Head == 4: Head = 0 else: Head +=1 return RecordRemoved
2(e)
Python def EnterRecord(): ID = input("Enter ID") QuantityP = input("Enter quantity") Record = SaleData(ID, QuantityP) if Enqueue(Record) == -1: print("Full") else: print("Stored")
2(f)(i)
EnterRecord() EnterRecord() Dim ReturnValue As SaleData = new SaleData ReturnValue = Dequeue() If (ReturnValue.SaleID = "") Then Console.WriteLine("No items") Console.WriteLine(ReturnValue.SaleID & " " & ReturnValue.Quantity) End If EnterRecord() For x = 0 To 4 Console.WriteLine(CircularQueue(x).SaleID & " " & CircularQueue(x).Quantity) Python EnterRecord() EnterRecord() EnterRecord() EnterRecord() EnterRecord() EnterRecord() ReturnValue = Dequeue() if ReturnValue.SaleID == "": print("No items") else: print(ReturnValue.SaleID, " ", ReturnValue.Quantity) EnterRecord() for x in range(0, 5): print(CircularQueue[x].SaleID, " ", CircularQueue[x].Quantity)
2(f)(ii) [1 mark]
1 mark for screenshot showing: Data for 6 records input 5 messages stating (e.g.) stored and 1 message stating (e.g.) full 1 output of ADF 10 (dequeued) Repeat successful input of LLP 3 Output of the 5 records
Outline the functions of the Transport and Internet layers of the TCP/IP protocol suite.
Transport layer
Internet layer 5 marks
Show mark scheme
2 [5 marks]
One mark for each point ( Max 3 ) MP1 The Transport Layer breaks data into manageable packets / performs segmentation MP2 It sequences the packets // adds data to the packet header // adds a packet MP3 It sends the packets to the Internet / Network Layer // It receives data from the Application Layer MP4 It controls the flow of packets MP5 It handles packet loss/corruption // Acknowledges receipt of complete error free packets One mark for each point ( Max 3 ) MP6 The Internet Layer identifies the intended network and host MP7 It transmits packets to the (Data) Link / Physical Layer MP8 It routes the packets independently through the optimum route MP9 It addresses packets with their source and destination IP addresses MP10 It then uses an IP address and port number to form a socket.
Lexical analysis and syntax analysis are stages in the compilation of a program.
(a) Identify two other stages that take place during the compilation of a program. 2 marks
1
2
(b) Outline the purpose of syntax analysis. 2 marks
Show mark scheme
2(a) [2 marks]
One mark per point • Code generation • Optimisation
2(b) [2 marks]
One mark per point ( Max 2 ) • It checks that the code matches the grammar of the language // It checks that the tokens conform with the rules of the programming language • Syntax errors are reported • A parse tree is produced.
Outline the functions of the Transport and Internet layers of the TCP/IP protocol suite.
Transport layer
Internet layer 5 marks
Show mark scheme
2 [5 marks]
One mark for each point ( Max 3 ) MP1 The Transport Layer breaks data into manageable packets / performs segmentation MP2 It sequences the packets // adds data to the packet header // adds a packet MP3 It sends the packets to the Internet / Network Layer // It receives data from the Application Layer MP4 It controls the flow of packets MP5 It handles packet loss/corruption // Acknowledges receipt of complete error free packets One mark for each point ( Max 3 ) MP6 The Internet Layer identifies the intended network and host MP7 It transmits packets to the (Data) Link / Physical Layer MP8 It routes the packets independently through the optimum route MP9 It addresses packets with their source and destination IP addresses MP10 It then uses an IP address and port number to form a socket.
Data types can be defined using pseudocode.
The data type, LibraryRecord, is defined in pseudocode as:
TYPE LibraryRecord
DECLARE Title : STRING
DECLARE Fiction : BOOLEAN
DECLARE Author : STRING
DECLARE NumberOfCopies : INTEGER
ENDTYPE
A variable, LibraryBook, is declared in pseudocode as:
DECLARE LibraryBook : LibraryRecord
(a) Write pseudocode statements to assign: 2 marks
A Level Computer SciencetoTitleofLibraryBookFALSEtoFictionofLibraryBook.
(b) The type definition for LibraryRecord is changed.
(i) The value for NumberOfCopies must be between 1 and 10 inclusive. 1 mark
Write the updated line of pseudocode from the type definition of LibraryRecord to
implement the change.
(ii) Every copy of every book is now uniquely identified by an accession number, AccessionNumber, as it is added to the library. Each library record will include one or more accession numbers. Each accession number is an integer. 2 marks
Write the extra line of pseudocode needed in the type definition of LibraryRecord .
Show mark scheme
1(a) [2 marks]
LibraryBook.Title "A Level Computer Science" LibraryBook.Fiction FALSE
1(b)(i) [1 mark]
DECLARE NumberOfCopies : 1 .. 10
1(b)(ii) [2 marks]
DECLARE AccessionNumber : ARRAY[1:NumberOfCopies] OF INTEGER
1(c) [3 marks]
two from A data type constructed by a programmer // not a primitive data type A data type that references at least one other data type… … the data types can be primitive, or user defined mark for an example Class / object / set
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: 2 marks
1067to theBuildingIDofBuildingRegisterhouseto theBuildingGroupofBuildingRegister
(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 marks
(ii) Write the new declaration for BuildingGroup in pseudocode . 1 mark
(iii) Write the new pseudocode statement to assign house to BuildingGroup of BuildingRegister . 1 mark
Show mark scheme
1(a) [2 marks]
BuildingRegister.BuildingID 1067 BuildingRegister.BuildingGroup "house"
1(b)(i) [2 marks]
mark: TYPE BuildingType = mark: (house, bungalow, apartment, farm) TYPE BuildingType = (house, bungalow, apartment, farm)
1(b)(ii) [1 mark]
DECLARE BuildingGroup : BuildingType
1(b)(iii) [1 mark]
BuildingRegister.BuildingGroup house
1(c)(i) [1 mark]
PRIVATE OwnerName : STRING
1(c)(ii) [2 marks]
To ensure that attributes can only be accessed by the class’s own methods To enforce encapsulation // ensure they are hidden
1 1 0 1
Data types can be defined using pseudocode.
The data type, LibraryRecord, is defined in pseudocode as:
TYPE LibraryRecord
DECLARE Title : STRING
DECLARE Fiction : BOOLEAN
DECLARE Author : STRING
DECLARE NumberOfCopies : INTEGER
ENDTYPE
A variable, LibraryBook, is declared in pseudocode as:
DECLARE LibraryBook : LibraryRecord
(a) Write pseudocode statements to assign: 2 marks
A Level Computer SciencetoTitleofLibraryBookFALSEtoFictionofLibraryBook.
(b) The type definition for LibraryRecord is changed.
(i) The value for NumberOfCopies must be between 1 and 10 inclusive. 1 mark
Write the updated line of pseudocode from the type definition of LibraryRecord to
implement the change.
(ii) Every copy of every book is now uniquely identified by an accession number, AccessionNumber, as it is added to the library. Each library record will include one or more accession numbers. Each accession number is an integer. 2 marks
Write the extra line of pseudocode needed in the type definition of LibraryRecord .
Show mark scheme
1(a) [2 marks]
LibraryBook.Title "A Level Computer Science" LibraryBook.Fiction FALSE
1(b)(i) [1 mark]
DECLARE NumberOfCopies : 1 .. 10
1(b)(ii) [2 marks]
DECLARE AccessionNumber : ARRAY[1:NumberOfCopies] OF INTEGER
1(c) [3 marks]
two from A data type constructed by a programmer // not a primitive data type A data type that references at least one other data type… … the data types can be primitive, or user defined mark for an example Class / object / set
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: 2 marks
Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse
(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 marks
Show mark scheme
3(a) [2 marks]
One mark for each marking point ( Max 2 ) • TYPE Parts = • (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse) Complete answer TYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse)
3(b) [2 marks]
One mark for each marking point ( Max 2 ) • TYPE SelectParts = ^ correct data type chosen • Parts Complete answer TYPE SelectParts = ^Parts
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: 2 marks
Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse
(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 marks
Show mark scheme
3(a) [2 marks]
One mark for each marking point ( Max 2 ) • TYPE Parts = • (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse) Complete answer TYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse)
3(b) [2 marks]
One mark for each marking point ( Max 2 ) • TYPE SelectParts = ^ correct data type chosen • Parts Complete answer TYPE SelectParts = ^Parts
(a) Describe the purpose of a user-defined data type. 2 marks
(b) Define, using pseudocode, the following enumerated data types:
(i) SchoolDay to hold data about the days students are usually in school. 1 mark
(ii) WeekEnd to hold data about the days that are not school days. 1 mark
(c) Define, using pseudocode, the composite data type ClubMeet . This will hold data about club members that includes: 4 marks
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) .
Show mark scheme
2(a) [2 marks]
One mark for each correct marking point (Max 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) [1 mark]
TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, Friday)
2(b)(ii) [4 marks]
TYPE WeekEnd = (Saturday, Sunday)
2(c)
One mark for each marking point ( Max 4 ) and correct • TYPE ClubMeet ENDTYPE and included with correct • DECLARE FirstName DECLARE LastName data types included with correct data types from part 2(b)(i) • DECLARE Schoolday included with correct data types from part 2(b)(ii) • DECLARE Weekend Example answer TYPE ClubMeet DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Schoolday : SchoolDay DECLARE Weekend : WeekEnd ENDTYPE
(a) Describe the purpose of a user-defined data type. 2 marks
(b) Define, using pseudocode, the following enumerated data types:
(i) SchoolDay to hold data about the days students are usually in school. 1 mark
(ii) WeekEnd to hold data about the days that are not school days. 1 mark
(c) Define, using pseudocode, the composite data type ClubMeet . This will hold data about club members that includes: 4 marks
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) .
Show mark scheme
2(a) [2 marks]
One mark for each correct marking point (Max 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) [1 mark]
TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, Friday)
2(b)(ii) [4 marks]
TYPE WeekEnd = (Saturday, Sunday)
2(c)
One mark for each marking point ( Max 4 ) and correct • TYPE ClubMeet ENDTYPE and included with correct • DECLARE FirstName DECLARE LastName data types included with correct data types from part 2(b)(i) • DECLARE Schoolday included with correct data types from part 2(b)(ii) • DECLARE Weekend Example answer TYPE ClubMeet DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Schoolday : SchoolDay DECLARE Weekend : WeekEnd ENDTYPE
(a) Describe the purpose of a user-defined data type. 2 marks
(b) Define, using pseudocode, the following enumerated data types:
(i) SchoolDay to hold data about the days students are usually in school. 1 mark
(ii) WeekEnd to hold data about the days that are not school days. 1 mark
(c) Define, using pseudocode, the composite data type ClubMeet . This will hold data about club members that includes: 4 marks
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) .
Show mark scheme
2(a) [2 marks]
One mark for each correct marking point (Max 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) [1 mark]
TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, Friday)
2(b)(ii) [4 marks]
TYPE WeekEnd = (Saturday, Sunday)
2(c)
One mark for each marking point ( Max 4 ) and correct • TYPE ClubMeet ENDTYPE and included with correct • DECLARE FirstName DECLARE LastName data types included with correct data types from part 2(b)(i) • DECLARE Schoolday included with correct data types from part 2(b)(ii) • DECLARE Weekend Example answer TYPE ClubMeet DECLARE FirstName : STRING DECLARE LastName : STRING DECLARE Schoolday : SchoolDay DECLARE Weekend : WeekEnd ENDTYPE