Programming – A Level Computer Science (9618)

153 questions · page 2 of 11

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
16
9618/21/O/N/25 · Question 7Oct/Nov 2025Paper 2110 marks
Loading question…
Question text

7
There are several different ways to express an algorithm during the design of a program.
(a) One part of the program contains an algorithm which is represented by a state-transition
diagram.
The table shows the inputs, outputs and states for the algorithm:
Current state
Input
Output
Next state
S1
A2
X2
S3
S1
A1
X1
S2
S2
A4
X4
S5
S3
A1
S3
S3
A3
X3
S2
S3
A2
X4
S4
S4
A1
X1
S4
S4
A3
S2
S4
A4
X4
S5
Complete the state-transition diagram to represent the information given in the table.
A2 | X2
START
S1
[5]
ĬÙĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
,
,
(b) A structure chart is used to document a different part of the program.
This part of the program contains six modules:
Pseudocode module header
PROCEDURE Setup()
PROCEDURE Restart(H1 : STRING, C1 : INTEGER)
FUNCTION Modify(B1 : BOOLEAN) RETURNS INTEGER
PROCEDURE Final(T1 : INTEGER)
PROCEDURE Update(BYREF R2 : STRING)
FUNCTION Confirm() RETURNS BOOLEAN
Module Setup will repeatedly call three of the modules.
Complete the structure chart to document the information given in the table.
Setup
H1
B1
R2
[5]
ĬÛĊ®Ġ´íÈõÏĪÅĊÝû·Ā×

17
9618/21/O/N/25 · Question 8Oct/Nov 2025Paper 2117 marks
Loading question…
Question text

8
A program is being developed to manage student book loans from a college library. Students may
borrow up to five books at a time from the library.
The programmer has defined a record type to define each loan.
The record data items are:
Data item
Data type
Comment
StudentID
STRING
the unique ID of the student who has borrowed the book
BookID
STRING
the unique ID of the book being borrowed
OnLoan
BOOLEAN
TRUE if the book has not been returned
The programmer has defined a global array Loan to store 5000 loan records.
There are more elements in the array than books in the library. Unused elements have the
StudentID set to an empty string. These may occur anywhere in the array.
The programmer has defined the first program module:
Module
Description
•
called with a parameter of type STRING representing a
StudentID
•
OKToBorrow()
search the array for loan records for the specified student
•
output a suitable message to say whether the student may, or
may not, borrow another book
ĬÕĊ®Ġ´íÈõÏĪÅĊÞü¶Ă×
,
,
(a) Write efficient pseudocode for the module OKToBorrow()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

18
9618/22/O/N/25 · Question 1Oct/Nov 2025Paper 2211 marks
Loading question…
Question text

1
(a) The table contains pseudocode examples.
Each example may contain statements that relate to one or more of:
•
selection
•
iteration (repetition)
•
subroutines (procedures or functions).
Complete the table by placing one or more ticks (‘3’) in each row.
Pseudocode example
Selection
Iteration
Subroutine
IF Status = FALSE THEN
FOR Count
1 TO 20
CALL Reset(Count)
NEXT Count
ENDIF
TRUE
OTHERWISE : Status
WHILE AllDone() = TRUE
'X'
30 : NextChar
[4]
(b) Complete the table by giving the appropriate data type.
Variable
Example data value
Data type
Result
5.42
MonthLetter
"JFMAMJJASOND"
Birthday
15/11/2009
[3]
(c) Evaluate each expression in the table by using the data values shown in (b).
Write ‘ERROR’ if the expression contains an error.
Expression
Evaluates to
INT(Result) + 1 > 6
NUM_TO_STR(LENGTH(MonthLetter))
NUM_TO_STR(Result + "3.2")
MID(MonthLetter, MONTH(Birthday) — 2, 1)
[4]
ĬÕĊ®Ġ´íÈõÏĪÅĊÞù¸þ×

Advertisement
19
9618/22/O/N/25 · Question 3Oct/Nov 2025Paper 2210 marks
Loading question…
Question text

3
A text file OldFile.txt contains IDs, names and email addresses for members of a club. Three
information items are stored for each member and each item is stored on a separate line.
The example shows the information for the first two members in the first six lines of the file:
Line in file
Information item
Example data
"AB1234"
1
member 1 ID
"Freddie Jones"
2
member 1 name
"[email protected]"
3
member 1 email address
"BC2345"
4
member 2 ID
"Sue Smith"
5
member 2 name
"[email protected]"
6
member 2 email address
The member ID string is always two letters followed by four digits.
The file design is to be changed so that information for each user is stored as a single line of the
file, with the character '\' used as a separator between data items.
For example, the single line for member 1 will be:
"AB1234\Freddie Jones\[email protected]"
An algorithm will produce a new file NewFile.txt from the contents of OldFile.txt
Assume:
•
LineX, LineY and LineZ are of type STRING and are used to store the three items of
information for each member
•
NewString is a temporary variable of type STRING
•
OldFile.txt exists and contains valid data.
(a) The algorithm to create the new file is expressed in steps.
Complete the following numbered steps:
Step 1 :
open the file … in …
Step 2 :
open the file … in …
Step 3 :
read a line from … and store in …
Step 4 :
read a line from … and store in …
Step 5 :
read a line from … and store in …
Step 6 :
set NewString to …
Step 7 :
write NewString to …
Step 8 :
repeat from step … until …
Step 9 :
close both files.
[6]
ĬÕĊ®Ġ´íÈõÏĪÅĊàù¸Ā×
,
,
(b) The character '\' has been chosen as a separator.
Explain why this is a suitable character.
…
… [1]
(c) Two new information items are to be stored for each member. Both new items are encrypted;
they can each contain any character (including '\') and can be of any length up to a
maximum of 99 characters.
For example:
Information item
Example data
"AB1234"
member 1 ID
"Freddie Jones"
member 1 name
"[email protected]"
member 1 email address
"En/98&*(|?\/D7iP"
member 1 new information 1
"23\CoboL"
member 1 new information 2
Explain the additional file design changes needed so that:
•
all the information items for each member are stored on a single line of NewFile.txt
•
it is possible to extract each information item after the line is read.
Assume the '\' character is not used in any email address.
…
…
…
…
…

20
9618/22/O/N/25 · Question 4Oct/Nov 2025Paper 2213 marks
Loading question…
Question text

4
A quiz has nine questions. There are:
•
five easy questions each worth 3 points
•
four hard questions each worth 5 points.
At the end of the quiz the points for each correctly answered question are added to give a total
score.
A check is made to test that the total score is valid using a 1D array CheckTotal of type BOOLEAN.
Each index value of the array represents a possible total score. The corresponding element value
is TRUE if the index value represents a valid total score and FALSE otherwise.
The first nine rows of the array are:
Index
Element
Comment
value
value
TRUE
0
valid total score (no correct answers)
FALSE
1
invalid total score
FALSE
2
invalid total score
TRUE
3
valid total score (one 3-point question correct)
FALSE
4
invalid total score
TRUE
5
valid total score (one 5-point question correct)
TRUE
6
valid total score (two 3-point questions correct)
FALSE
7
invalid total score
TRUE
8
valid total score (one 3-point question and one 5-point question correct)
For example, a total score of 6 points is valid; the value of the array element at index value 6 is TRUE
(a) Write pseudocode to declare CheckTotal and to set all elements of the array to FALSE
All variables used must be declared.
…
…
…
…
…
…
…
… [4]
ĬÙĊ®Ġ´íÈõÏĪÅĊÝûµþ×
,
,
(b) The pseudocode represents an algorithm to set the appropriate elements of the array to TRUE
Complete the pseudocode:
DECLARE EasyQ, HardQ : INTEGER
… TO 15 STEP …
FOR EasyQ
0 TO … STEP …
FOR HardQ
TRUE
CheckTotal[ … ]
NEXT HardQ
NEXT EasyQ
[5]
(c) The array elements have been assigned the required values.
A module ValidateScore() will take an integer value representing a total score as a
parameter. It will return TRUE if the total score is valid, or FALSE if it is not valid.
Describe the algorithm for ValidateScore() using four steps.
Do not use pseudocode in your answer.
Step 1 …
…
Step 2 …
…
Step 3 …
…

21
9618/22/O/N/25 · Question 6Oct/Nov 2025Paper 227 marks
Loading question…
Question text

6
A string function Compare() will compare two strings.
The function will:
•
take four parameters:
○ two strings, String1 and String2
○ a character, Position, to indicate whether String1 will be compared with the start
('s'), or the end ('e') of String2
○ a Boolean, CaseMatters, to indicate whether an upper case character and lower case
character (for example, 'A' and 'a') are regarded as different (TRUE), or as the same
(FALSE)
•
return FALSE if String2 has fewer characters than String1
•
return TRUE if the comparison is true, otherwise return FALSE
For example:
Parameter
Return
value
String1
String2
CaseMatters
Position
TRUE
"Cat"
"Catalogue"
TRUE
's'
FALSE
"CAT"
"Catalogue"
TRUE
's'
TRUE
"CAT"
"Catalogue"
FALSE
's'
FALSE
"Cat"
"Catalogue"
TRUE
'e'
TRUE
"GUE"
"Catalogue"
FALSE
'e'
FALSE
"Catalogue"
"Cat"
TRUE
's'
ĬÙĊ®Ġ´íÈõÏĪÅĊÞû·þ×
,
,
Write pseudocode for the function Compare()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

22
9618/22/O/N/25 · Question 8Oct/Nov 2025Paper 2218 marks
Loading question…
Question text

8
A program is being developed to manage student book loans from a college library.
The programmer has defined a record type to define each loan.
The data items are:
Data item
Data type
Comment
StudentID
STRING
the unique ID of the student who has borrowed the book
BookID
STRING
the unique ID of the book being borrowed
OnLoan
BOOLEAN
TRUE if the book has not been returned
The programmer has defined a global array Loan to store 7000 loan records.
There are more elements in the array than books in the library. Unused elements have the
StudentID set to an empty string. These may occur anywhere in the array.
The programmer has defined a program module:
Module
Description
•
called with a parameter of type STRING representing a
StudentID
•
counts the number of books currently on loan to the
specified student
CountLoans()
•
counts the number of books that the student has already
returned
•
output both counts together with a suitable message
ĬÕĊ®Ġ´íÈõÏĪÅĊßú¶Ă×
,
,
(a) Write pseudocode for module CountLoans()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

23
9618/23/O/N/25 · Question 1Oct/Nov 2025Paper 2312 marks
Loading question…
Question text

1
A user requires a program that implements complex data encryption to a recognised international
standard. A programmer has started the design of the program.
(a) The programmer decides to use a library routine to provide part of the solution. One reason
for this is that library routines may perform functions that the programmer is unable to program
themselves.
State three other benefits of using library routines in the development of the program.
1 …
…
2 …
…
3 …
…
[3]
(b) The programmer has identified a different part of the algorithm that would be appropriate to
implement as a subroutine (a procedure or a function); no suitable library routine exists for
this part.
(i)
State two reasons why the programmer may decide to use a subroutine.
1 …
…
2 …
…
[2]
(ii)
A function header in pseudocode is defined as:
FUNCTION Pass2(Count : INTEGER) RETURNS BOOLEAN
Complete the table by describing the terms used in the function header.
The first row has been completed.
Term
Description
Pass2
the name of the function
Count
BOOLEAN
[2]
ĬÍĊ¾Ġ´íÈõÏĪÅĊàû·þ×
,
,
(c) Variables in the program have example values:
Variable
Example value
DoB
23/6/2011
Multiplier
2.5
AddressLine[1]
"35 Lincoln Avenue"
Complete the table by evaluating each expression using the example values:
Expression
Evaluates to
LENGTH(NUM_TO_STR(Multiplier))
MONTH(DoB) > 4
15 + STR_TO_NUM(MID(AddressLine[1], 2, 1))
[3]
ĬÏĊ¾Ġ´íÈõÏĪÅĊàù·þ×

Advertisement
24
9618/23/O/N/25 · Question 3Oct/Nov 2025Paper 236 marks
Loading question…
Question text

3
A program uses a stack to hold up to 30 integer values. The stack is implemented using a global
integer variable and a global 1D array.
The array is declared in pseudocode:
DECLARE ThisStack : ARRAY[1:30] OF INTEGER
Stack design notes:
•
The global variable SP acts as a stack pointer. SP contains the array index of the last value
pushed onto the stack.
•
If the stack is empty, then SP is assigned the value zero.
•
The first item added to the stack will be stored in ThisStack[1]
•
SP is incremented each time an item is added to the stack.
A function Pop() is written to remove an item from ThisStack. The function returns an item of
type PopData which is defined in pseudocode:
TYPE PopData
DECLARE Data
: INTEGER
DECLARE Exists : BOOLEAN
ENDTYPE
The value removed from the stack is assigned to Data and Exists is set to TRUE. If it is not
possible to remove a value from the stack, then Exists is set to FALSE
Complete the pseudocode for Pop()
FUNCTION Pop() RETURNS PopData
DECLARE ThisPop : …
IF … THEN
… // Stack is empty
PopData.Exists
ELSE
…
PopData.Data
…
PopData.Exists
…
SP
ENDIF
RETURN ThisPop
ENDFUNCTION
[5]
ĬÑĊ¾Ġ´íÈõÏĪÅĊßù¶þ×

25
9618/23/O/N/25 · Question 4Oct/Nov 2025Paper 236 marks
Loading question…
Question text

4
A program contains a global 1D array Data containing 20 elements of type INTEGER
A global string NumString represents a sequence of three-digit numbers, separated by commas.
For example:
"101,456,219,754,328"
The string contains at least four three-digit numbers. The total number of three-digit numbers in
the string is unknown.
A procedure Store() will:
•
extract one three-digit number at a time from NumString
•
convert each of the three-digit numbers extracted to an integer and assign this to the next
array element, starting from index 1
•
end when all three-digit numbers have been stored, or when the array is full.
Complete the pseudocode for Store()
All local variables used must be declared.
PROCEDURE Store()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
ENDPROCEDURE
[6]
ĬÑĊ¾Ġ´íÈõÏĪÅĊÝù¶Ā×
,
,
ĬÓĊ¾Ġ´íÈõÏĪÅĊÝû¶Ā×

26
9618/23/O/N/25 · Question 5Oct/Nov 2025Paper 2328 marks
Loading question…
Question text

5
A global 1D array Num of integers contains four elements. A program assigns values to these
elements as shown:
1
Num[1]
2
Num[2]
5
Num[3]
3
Num[4]
A procedure Process() manipulates the values in the array.
The procedure is written in pseudocode:
PROCEDURE Process(Start : INTEGER)
DECLARE CaseVar, Index, Count : INTEGER
Start
Index
0
Count
WHILE Count <= 20
CaseVar Num[Index]
CASE OF CaseVar
1 : Num[Index] Num[Index] + Index //clause one
Index Index + 1
Count Count + 1
2 : Num[Index] Num[Index] + Index //clause two
Index Index + 2
Count Count + 2
3 : Num[Index] Num[Index] * 2
//clause three
Index Index + 3
Count Count - 1
4 : Count Count + 4
//clause four
OTHERWISE : Count 20
ENDCASE
(Index MOD 4) + 1
Index
ENDWHILE
ENDPROCEDURE
ĬÑĊ¾Ġ´íÈõÏĪÅĊàù¸þ×
,
,
(a) Complete the trace table by dry running the procedure when it is called in the statement:
CALL Process(1)
Index
CaseVar
Count
Num[1]
Num[2]
Num[3]
Num[4]
[5]
ĬÓĊ¾Ġ´íÈõÏĪÅĊàû¸þ×
,
,
(b) As a reminder, the CASE structure in the pseudocode is:
CASE OF CaseVar
1 : Num[Index] Num[Index] + Index //clause one
Index Index + 1
Count Count + 1
2 : Num[Index] Num[Index] + Index //clause two
Index Index + 2
Count Count + 2
3 : Num[Index] Num[Index] * 2
//clause three
Index Index + 3
Count Count - 1
4 : Count Count + 4
//clause four
OTHERWISE : Count 20
ENDCASE
The CASE structure could be optimised by combining two existing clauses.
(i)
Identify the CaseVar values for these two existing clauses.
… [1]
(ii)
Write pseudocode for a single clause to replace the two clauses identified in (b) (i).
…
…
… [2]
ĬÑĊ¾Ġ´íÈõÏĪÅĊÞù¸Ā×

27
9618/23/O/N/25 · Question 6Oct/Nov 2025Paper 239 marks
Loading question…
Question text

6
Students are learning about a simple check digit method for data validation. In this method, a
single check digit is appended to the end of an original number to give a new number.
The students are studying a method which:
•
calculates the sum of all the digits in the original number
•
uses integer division to calculate the remainder when the sum is divided by 10
•
uses the remainder as the check digit
•
appends the check digit to the original number, creating the new number.
For example:
original number
4162
sum of all digits
4 + 1 + 6 + 2 = 13
remainder when the sum is divided by 10 using integer division
3
new number
41623
The original number is always at least three digits in length.
When the new number is input, the check digit is used to validate the new number.
(a) A function Generate() is written to take an original number as a parameter and to return the
check digit.
Outline a test plan that could be used to fully test function Generate()
Assume that the parameter is valid.
…
…
…
… [2]
ĬÍĊ¾Ġ´íÈõÏĪÅĊÝüµĂ×
,
,
(b) A function CheckNumber() will take an integer value and return the Boolean value TRUE if
the check digit is correct, otherwise return FALSE
Write pseudocode for the function CheckNumber()
Assume that the parameter is valid.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

28
9618/23/O/N/25 · Question 7Oct/Nov 2025Paper 239 marks
Loading question…
Question text

7
There are several different ways to express an algorithm during the design of a program.
(a) One part of the program contains an algorithm which is represented by a state-transition
diagram.
The table shows the inputs, outputs and states for the algorithm:
Current state
Input
Output
Next state
S1
A1
S2
S2
A2
X4
S3
S3
A1
X1
S3
S3
A2
X1
S3
S3
A3
X3
S4
S3
A4
S2
S4
A3
X4
S5
S4
A4
X4
S5
S4
A1
S2
Complete the state-transition diagram to represent the information given in the table:
START
S1
[5]
ĬÍĊ¾Ġ´íÈõÏĪÅĊßüµĄ×
,
,
(b) A structure chart is used to document a different part of the program, made up of five modules.
Program notes:
•
module Setup calls either module Restart, or module Confirm
•
module Confirm takes a string as a parameter and returns an integer
•
module Modify has no parameters and returns a Boolean
•
module Update takes a string as a parameter
•
module Restart repeatedly calls module Update followed by module Modify
•
module Restart takes a string as a parameter that is passed by reference.
Draw a structure chart to represent the relationship between the five modules, including all
parameters and return values.
[4]
ĬÏĊ¾Ġ´íÈõÏĪÅĊßúµĄ×

Advertisement
29
9618/23/O/N/25 · Question 8Oct/Nov 2025Paper 2320 marks
Loading question…
Question text

8
A program is being developed to manage student book loans from a college library.
The programmer has defined a record type to define each loan.
The data items are:
Data item
Data type
Comment
the unique ID of the student who has borrowed
the book
StudentID
STRING
The first three characters of a StudentID
represent a tutor ID. Each student has one tutor.
BookID
STRING
the unique ID of the book being borrowed
OnLoan
BOOLEAN
TRUE if the book has not been returned
The programmer has defined a global array Loan to store 8000 loan records.
There are more elements in the array than books in the library. Unused elements have the
StudentID set to an empty string. These may occur anywhere in the array.
The programmer has defined a program module:
Module
Description
•
called with two parameters of type STRING representing a
StudentID and a BookID
•
outputs a message saying whether a given loan has been
LoanStatus()
returned or not
•
outputs a warning message if a record of the given loan is
not found
ĬÍĊ¾Ġ´íÈõÏĪÅĊÞü·Ă×
,
,
(a) Write efficient pseudocode for the module LoanStatus()
Assume that each combination of StudentID and BookID can occur only once.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

30
9618/21/M/J/25 · Question 1May/June 2025Paper 2116 marks
Loading question…
Question text

1
A program is being developed to help the manager of a shop control the stock.
(a) An identifier table has been used during the design stage.
Complete the identifier table:
Example value
Explanation
Variable name
Data type
a category of stock
"Fruit"
that is sold in the shop
when an item was
20/02/2025
sold
12.67
the cost of an item
to indicate if an item is
TRUE
in stock
[4]
(b) A module Sales() is part of the stock control program.
The table contains pseudocode extracts from the module Sales()
Each extract may include all or part of:
•
assignment
•
selection
•
iteration (repetition).
Complete the table by placing one or more ticks (✓) in each row:
Pseudocode extract
Assignment
Selection
Iteration
CalculateTotal()
Result
WHILE IsClosed
REPEAT
INPUT Value
UNTIL Sales[4] > Value
IF Sales[Current] <= 150 THEN
TRUE
Discount
ENDIF
CASE OF Option
[5]
ĬÕĊ®Ġ´íÈõÏĪÅĊÞú¸þ×
,
,
(c) Decomposition has been used to design the program to help the shop manager control the
stock.
Describe decomposition.
…
…
…
…
…
… [3]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊÞü¸þ×

Advertisement