9618/23

Computer Science 9618/23May/June 2025

Cambridge AS Level · Fundamental Problem-solving and Programming Skills · worked solutions for every part, with the mark scheme

7
questions
75
marks
120
minutes

Topics Programming · Data Types and Structures · Algorithm Design and Problem-solving · Software Development

Q1MediumAlgorithm Design and Problem-solvingProgrammingData Types and Structures

A program is being developed for the management of a sports centre.

(a)

The programmer developing the software decides to use modules (procedures or functions) and local variables. They also decide not to use global variables.

5M
(i)

State two reasons why the programmer decides to use modules.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

2M
(ii)

State one difference between local and global variables.

...........................................................................................................................................

.....................................................................................................................................

1M
(iii)

State two benefits of using local variables.

1 ........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

2M
(b)

The pseudocode design contains a number of expressions.

Complete each pseudocode expression so that it evaluates to the value shown.

Refer to the insert for the list of pseudocode functions and operators.

ExpressionEvaluates to
................................(68)'D'
................................(04/02/2025)2
................................TRUEFALSE
................................(................................ ("Court1.4Upper" ,..........,...........))1.4
5M
(c)

The table lists some of the variables used in the program.

Complete the table by writing the most appropriate data type for each variable.

VariableUse of variableData type
MemberCountstores how many members have used the sports centre each day
TotalTakingsstores the total amount of money taken each day
BookingConfirmedstores the state of a booking for an exercise class; a booking is either confirmed or not confirmed
MemberDOBto calculate when to send an email with a birthday message to a member
4M
Q2MediumData Types and Structures

A programmer uses a number of Abstract Data Types (ADT) in the programs that she is developing.

(a)

A stack using memory locations 400 to 409 is used in one program.

The diagram represents the current state of the stack.

A variable TopOfStack pointer indicates the last value added to the stack.

5M
(i)

Complete the answer column in the following table:

Answer
the memory location of the value that has been on the stack for the longest time
the number of consecutive push operations that will result in the TopOfStack variable containing 409
2M
(ii)

The diagram shows the current state of the stack.

The following sequence of operations are performed:

PUSH 'T'
POP
POP
PUSH 'Z'
PUSH 'X'
POP
PUSH 'Y'

Complete the following diagram to show the state of the stack after the operations have been performed.

3M
(b)

In a different program, the programmer decides to implement a linked list using an array of records.

4M
(i)

The array is represented in the diagram.

A pointer value of -1 indicates the end of the linked list.

Complete the pointer field to produce a linked list that is in alphabetical order.

IndexDataPointer
0"Neptune"
1"Jupiter"
2"Saturn"
3"Earth"
4"Mercury"
5"Uranus"
3M
(ii)

The variable StartPointer contains the index of the first item in the linked list.

State the value of the variable StartPointer

.....................................................................................................................................

1M
(c)

A third program is also being created to manage a queue.

Describe two features of a queue.

Feature one ..............................................................................................................................

...................................................................................................................................................

Feature two ...............................................................................................................................

...................................................................................................................................................

2M
Q37MMediumAlgorithm Design and Problem-solvingProgramming

A programmer has been asked to create a module RollDice() to simulate multiple rolls of a dice. This module will be used as part of a program for a game.

The module will:

step 1 – take a positive integer parameter representing the number of times the dice will be rolled

step 2 – simulate one roll of the dice by generating a random integer between 1 and 6 inclusive

step 3 – output the integer generated

step 4 – repeat, as required from step 2

step 5 – calculate the average value of the random integers generated

step 6 – return the average value.

Write pseudocode for the module RollDice()

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

....................................................................................................................................................

Similar questions
Q4Medium-EasyAlgorithm Design and Problem-solvingData Types and StructuresSoftware Development

A programmer is developing a new stock control program for a shop owner to produce sales reports.

(a)

A text file Sales.txt stores strings representing the number of items sold.

The file contains 52 lines, each representing the number of items sold in each week of the year.

For example:

File line numberFile data
1"350"
2"502"
3"434"
......
49"492"
50"872"
51"772"
52"201"

The example shows that 502 items were sold in week 2.

The owner requires a module to output all week numbers where the number of items sold is greater than 500.

Describe an algorithm that produces the required module.

Do not include pseudocode statements in your answer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

5M
(b)

Once the program has been completed, it is tested using the walkthrough method.

Describe the walkthrough method and explain how it can be used to identify errors.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

3M
Q58MMediumProgramming

A module Parity() takes a string as a parameter. The parameter has the identifier BitString and it represents a binary value.

The module will concatenate a single character to the end of BitString by applying one of the two rules:

• '0' if BitString contains an even number of 1s
• '1' if BitString contains an odd number of 1s.

The modified value of BitString is then returned.

For example:

ParameterString returnedExplanation
"0010010110""00100101100"there are an even number of 1s in the string passed to Parity() so a '0' is concatenated to the end of BitString
"101010""1010101"there are an odd number of 1s in the string passed to Parity() so a '1' is concatenated to the end of BitString

Write pseudocode for the module Parity()

Assume the parameter BitString can only contain the characters '0' and '1'

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

....................................................................................................................................................

Similar questions
Q6MediumProgrammingSoftware Development

Study the structure chart:

Some of the parameter data types are:

• R and V are of type INTEGER
• T is of type REAL
• U is of type STRING
• W is of type BOOLEAN.

Some of the modules in the structure chart are functions, others are procedures.

(a)

Explain one difference between functions and procedures.

...................................................................................................................................................

.............................................................................................................................................

1M
(b)

Write the pseudocode to define the module headers:

Sub_Part1A

...................................................................................................................................................

...................................................................................................................................................

Sub_Part2A

...................................................................................................................................................

...................................................................................................................................................

Sub_Part3A

...................................................................................................................................................

...................................................................................................................................................

5M
(c)

The structure chart uses the two symbols shown.

Complete the table to explain what each symbol means and how the relevant modules in the structure chart are affected.

SymbolExplanation

| ........................................................................................................................
........................................................................................................................ |
|

| ........................................................................................................................
........................................................................................................................ |

3M
Q7Medium-HardProgrammingData Types and Structures

A program is being developed to implement a customer loyalty scheme for a coffee shop.

The programmer has decided that the following data items need to be stored for each customer:

Data itemDescription
customer IDa unique six-digit string
loyalty pointsan integer value that depends on how often the customer visits the coffee shop
last visit datethe date the customer last visited the coffee shop

The programmer has defined a program module:

ModuleDescription
UpdateVisit()• called with two parameters:
1. loyalty points of type INTEGER
2. last visit date of type DATE
• change the loyalty points:
- increase by four if the last visit date and the current date are in the same month
- otherwise increase by one
• change the last visit date to the current date
• the changed values must be available to the code that follows the call to UpdateVisit()
(a)
6M
(i)

Write pseudocode for module UpdateVisit()

Assume the customer has made at least one previous visit.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

5M
(ii)

The programmer decides to amend the UpdateVisit() module so that loyalty points are further increased if the customer visits the coffee shop the same day of the week as their last visit.

Write the pseudocode for this condition.

...........................................................................................................................................

.....................................................................................................................................

1M
(b)

A text file Loyalty.txt will be used to store the data items for the loyalty scheme.

The text file Loyalty.txt contains only one line of data for each customer.

Each data item is separated by a comma:

<CustomerID>,<LoyaltyPointsString>,<LastVisitDateString>

LastVisitDateString is always eight characters in length in the format: DDMMYYYY.

An example of how a line of data will be stored in the text file Loyalty.txt is:

"100123,132,05032025"

This example shows that the customer with an ID of 100123 had 132 loyalty points following their last visit to the coffee shop on 05/03/2025.

If a customer visits the coffee shop on a Monday, the value of their loyalty points is increased by 10.

The programmer has defined two more program modules:

ModuleDescription
FindCustomer()
(is already written)
• called with a parameter of type STRING that represents a customer ID
• returns the line of data read from the text file Loyalty.txt containing the data items for that customer
MondayCheck()• called with a parameter of type STRING that represents the customer ID of a customer
• calls FindCustomer()
• extracts the loyalty points from the string returned by FindCustomer()
• increases the loyalty points for the current customer by 10 if the day visited is a Monday
• returns an integer value representing the loyalty points
12M
(i)

Write pseudocode for module MondayCheck()

The module FindCustomer() must be used and assume it returns a valid string for the current customer.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

8M
(ii)

A date is stored in LastVisitDateString in the format:

DDMMYYYY

DD is a 2-digit string
MM is a 2-digit string
YYYY is a 4-digit string.

For example, the date 03/09/2024 is stored as "03092024"

An algorithm is needed to convert the string stored in LastVisitDateString to data type DATE which is then stored in the variable LastVisitDate.

Complete the pseudocode for this algorithm:

Assume that LastVisitDateString has been declared and contains valid data.

DECLARE DayInt, MonthInt, YearInt : INTEGER
DECLARE LastVisitDate : DATE
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
4M