BREAKING
Student's code works, nobody knows why, including student★Local teen writes pseudocode, accidentally invents a language★Binary joke told in class, exactly 10 students laugh★
  1. Home
  2. A Level
  3. Computer Science
  4. OCR
  5. Designing, creating and refining algorithms

OCR A Level Computer Science

Topic questions Algorithms Designing, creating and refining algorithms

Designing, creating and refining algorithms

15 questions · 269 marks · about 5 hours

Designing, creating and refining algorithms questions

OCR H446 Designing, creating and refining algorithms 15 questions

Algorithms and programming June 2025, Question 6 18 marks

Also involves Arrays

A student is writing a program in a high-level programming language.

(a)

The student writes the program using an Integrated Development Environment (IDE).

Complete the table by identifying and describing three features of an IDE that the student can use to debug their program.

Figure for question 6
[6]
Reveal mark scheme Mark scheme for question 6(a)
(b)

The program the student is developing includes both global and local variables.

(b)(i)

Explain the difference between a global variable and a local variable.

[2]
Reveal mark scheme Mark scheme for question 6(b)(i)
(b)(ii)

Describe one drawback of using global variables in a program.

[2]
Reveal mark scheme Mark scheme for question 6(b)(ii)
(b)(iii)

Describe one drawback of using local variables in a program.

[2]
Reveal mark scheme Mark scheme for question 6(b)(iii)
(c)

A variable can be passed as a parameter into a function by value or by reference.

Describe what parameter passing by value means.

[2]
Reveal mark scheme Mark scheme for question 6(c)
(d)

An algorithm is needed to count how many times each of the numbers from 1 to 9 appear in an array called myArray. Another array called checked is used to store each number found in myArray and the number of times it appears. For example, the contents of myArray are:

Figure for question 6

Based on these contents in myArray, the contents in checked would be:

72
33
62
51
21
–10
–10
–10
–10

–1 indicates an unused space in the array as the numbers 1, 4, 8 and 9 have not been found.

The student has written the following pseudocode for this program.

The pseudocode contains several errors.

Figure for question 6

Identify the line number of any four errors and write the corrected line for each error.

Error 1

Error 2

Error 3

Error 4

[4]
Reveal mark scheme Mark scheme for question 6(d)

Computer systems June 2023, Question 2 22 marks

Sundip writes an algorithm to carry out addition and subtraction. The algorithm will use an initially empty stack with the identifier numbers and will take input from the user.

The action the algorithm takes depends on the value input by the user. These actions are listed in

Figure for question 2
(a)

Complete the pseudocode here to implement Sundip’s algorithm.

Figure for question 2
[5]
Reveal mark scheme Mark scheme for question 2(a)
(b)(i)
Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(b)(i)
(b)(ii)

Complete the following table to give the output from this algorithm when the following set of inputs are entered by the user. The letters will complete an action stated in Fig. 2

Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(b)(ii)
(b)(iii)

If the user enters 4 2 S A E, the algorithm will not work correctly.

Explain what problem this input data will cause and why the problem occurs.

[3]
Reveal mark scheme Mark scheme for question 2(b)(iii)
(c)

A stack is one data structure that is available for Sundip to use. She could also use a queue, list, linked list, array or tuple.

(c)(i)

Describe one difference between a stack and a queue.

[2]
Reveal mark scheme Mark scheme for question 2(c)(i)
(c)(ii)

Describe one difference between an array and a list.

[2]
Reveal mark scheme Mark scheme for question 2(c)(ii)
(c)(iii)

State how a tuple is different to a list.

[1]
Reveal mark scheme Mark scheme for question 2(c)(iii)
(c)(iv)

Describe how the second item in a linked list would be accessed using pointer values.

[3]
Reveal mark scheme Mark scheme for question 2(c)(iv)

Computer systems June 2023, Question 5 6 marks

Also involves File handling

A doCheck() function takes an integer value as a parameter, carries out a series of calculations and returns an integer value.

The function is shown here.

Figure for question 5
(a)

State the value returned from the function when doCheck(3178) is called.

[1]
Reveal mark scheme Mark scheme for question 5(a)
(b)

Write an algorithm that will:

• allow the user to enter an integer value

• pass the value entered into the doCheck() function as a parameter

• store both the value input and the value returned from the function in a text file with name "storedvalues.txt"

You should write your algorithm using either pseudocode or program code.

[5]
Reveal mark scheme Mark scheme for question 5(b)

Computer systems June 2022, Question 5 30 marks

A programmer creates this function shown in Fig. 5 using a high-level language.

Figure for question 5
(a)(i)

State the value output by the line print(mystery(10,20))

[1]
Reveal mark scheme Mark scheme for question 5(a)(i)
(a)(ii)

State the value output by the line print(mystery(0,70))

[1]
Reveal mark scheme Mark scheme for question 5(a)(ii)
(a)(iii)

State the value output by the line print(mystery(45,55))

[1]
Reveal mark scheme Mark scheme for question 5(a)(iii)
(b)

Before the code in Fig. 5 can be executed, a translator must be used.

(b)(i)

State the purpose of a translator.

[1]
Reveal mark scheme Mark scheme for question 5(b)(i)
(b)(ii)

Explain two differences between a compiler and an interpreter.

[4]
Reveal mark scheme Mark scheme for question 5(b)(ii)
(c)

For each statement shown in Table 5, tick (✓) one box in each row to indicate which stage of compilation each action takes place at.

Figure for question 5
[5]
Reveal mark scheme Mark scheme for question 5(c)
(d)

Describe the purpose of code optimisation.

[2]
Reveal mark scheme Mark scheme for question 5(d)
(e)

The programmer creates another function to count and return how many capital letters are in a string that is passed into the function as a parameter.

The asc() function takes in a character and returns its ASCII value. For example asc("A") returns 65. Capital letters have ASCII values between 65 and 90 inclusive.

(e)(i)
Figure for question 5
[3]
Reveal mark scheme Mark scheme for question 5(e)(i)
(e)(ii)

Give one similarity between ASCII and Unicode.

[1]
Reveal mark scheme Mark scheme for question 5(e)(ii)
(e)(iii)

Give two differences between ASCII and Unicode.

[2]
Reveal mark scheme Mark scheme for question 5(e)(iii)
(f)

* The programmer has been asked by a client to create a complex computer program. Compare the spiral model and waterfall lifecycle methodologies for this task.

You should include the following in your answer:

• how both methodologies could be used to develop a complex computer program

• the benefits of each methodology for this task

• the drawbacks of each methodology for this task.

[9]
Reveal mark scheme Mark scheme for question 5(f)

Computer systems November 2021, Question 6 24 marks

A program written using the Little Man Computer instruction set is shown in Fig. 1.

Figure for question 6
(a)

Various registers are used when the program above is executed.

(a)(i)

State what is meant by the term ‘register’.

[2]
Reveal mark scheme Mark scheme for question 6(a)(i)
(a)(ii)

Explain how the accumulator is used when the line BRP pos is executed.

[2]
Reveal mark scheme Mark scheme for question 6(a)(ii)
(b)

Complete the table below to show the output(s) from this program given the inputs.

Figure for question 6
[4]
Reveal mark scheme Mark scheme for question 6(b)
(c)

Write an algorithm using pseudocode that has the same functionality as the code in Fig. 1

[4]
Reveal mark scheme Mark scheme for question 6(c)
(d)

* In assembly language, different modes of addressing memory can be used.

Discuss the different modes used. You should include:

• How the operand value is determined

• What an operand of 27 would refer to in that mode

• The reasons for requiring multiple modes of addressing

[12]
Reveal mark scheme Mark scheme for question 6(d)

Algorithms and programming November 2021, Question 8 40 marks

Also involves Syntax and logic errors · Arrays

Figure for question 8
(a)

Juan is creating a structure diagram to design the game.

(a)(i)
Figure for question 8
[3]
Reveal mark scheme Mark scheme for question 8(a)(i)
(a)(ii)

A structure diagram is one method of showing the decomposition of a problem.

Explain why decomposing a problem can help a developer design a solution.

[2]
Reveal mark scheme Mark scheme for question 8(a)(ii)
(a)(iii)

Identify one input, one process and one output required for the game.

[3]
Reveal mark scheme Mark scheme for question 8(a)(iii)
(b)

Juan uses the structure diagram to create a modular program with a number of subroutines. The program will use two integer 2-dimensional arrays to store the puzzles:

• puzzle(5,5) stores the solution

• answerGrid(5,5) stores the user’s current grid.

A 0 represents a white box and a 1 represents a black box.

(b)(i)
Figure for question 8
[5]
Reveal mark scheme Mark scheme for question 8(b)(i)
(b)(ii)

Explain the purpose of line 03 in the function countRow.

[2]
Reveal mark scheme Mark scheme for question 8(b)(ii)
(b)(iii)

Describe the purpose of branching and iteration in the function countRow.

[3]
Reveal mark scheme Mark scheme for question 8(b)(iii)
(b)(iv)
Figure for question 8
[6]
Reveal mark scheme Mark scheme for question 8(b)(iv)
(b)(v)

The function checkWon() takes answerGrid and puzzle as parameters and compares each element in the grids. If they are identical, it returns true, otherwise returns false.

Figure for question 8

There are three logic errors in the function checkWon.

State the line number of each error and give the corrected line.

Error 1 line number........

Error 1 correction........

Error 2 line number........

Error 2 correction........

Error 3 line number........

Error 3 correction........

[3]
Reveal mark scheme Mark scheme for question 8(b)(v)
(c)

* Juan passed the two arrays as parameters, but he did consider making them globally accessible.

Compare the use of global and local variables and data structures in this program. Include the use of parameters and program efficiency in your answer.

[9]
Reveal mark scheme Mark scheme for question 8(c)
(d)

Juan wants to create a program that will generate new Nonograms with different grid sizes. For example a Nonogram with a 10 × 10 grid or a 5 × 20 grid.

Describe how the program could be written to automatically generate a new Nonogram.

[4]
Reveal mark scheme Mark scheme for question 8(d)

Computer systems November 2020, Question 6 8 marks

Also involves Sequence, selection and iteration · Input validation

Two people play a counting game. The rules of the game are as follows:

• The first player starts at 1

• Each player may choose one, two or three numbers on their turn and the numbers must be in ascending order

• Players take it in turns to choose

• The player who chooses “15” loses the game.

For example, if the first player chooses three numbers (1, 2, 3) then the second player could choose one number (4), two numbers (4, 5) or three numbers (4, 5, 6). The first player then takes another go.

Write an algorithm using pseudocode that allows two players to play this game. The algorithm should:

• Alternate between player 1 and player 2

• Ask the player how many numbers they would like to choose, ensuring that this is between 1 and 3

• Display the numbers that the player has chosen

• Display a suitable message to say which player has won once the number 15 has been displayed.

[8]
Reveal mark scheme Mark scheme for question 6

Computer systems June 2019, Question 2 11 marks

Also involves String manipulation

A survey is carried out to look at the types of vehicle that travel down a stretch of motorway.

For each vehicle that passes by, a letter is entered into the system.

For a car ‘C’ is entered.

For a motorbike ‘M’ is entered.

For a lorry ‘L’ is entered.

For any other vehicle ‘O’ is entered.

It is decided to compress the data that has been generated.

(a)

State what is meant by the term ‘compression’.

[1]
Reveal mark scheme Mark scheme for question 2(a)
(b)

It is decided that Run Length Encoding will be used.

The following sequence has been compressed using Run Length Encoding.

3C3M4C

Show the result of decompressing the sequence.

[2]
Reveal mark scheme Mark scheme for question 2(b)
(c)

Show the result of using Run Length Encoding to compress the sequence:

CCCCOLLLCCCCCMOCCCCC

[3]
Reveal mark scheme Mark scheme for question 2(c)
(d)

The survey takers want to find out the longest continuous sequence of cars in any given chunk of data. For example, in the data

CCMCCCCLLCCC

the longest sequence would be 4.

Write the function longest which takes in a string of characters as an argument and returns an integer representing the longest continuous sequence of Cs.

[5]
Reveal mark scheme Mark scheme for question 2(d)

Computer systems June 2019, Question 5 23 marks

Also involves String manipulation

A programmer is writing software for a firewall. She is writing code so that it keeps a track of websites that users are permitted to visit. The software stores the websites’ addresses along with details about who can view them and when.

The following data is also stored about each website:

• Access level needed (1-4) • If it is available all the time (true) or just lunch times and out of work hours (false).

So a website which is available to users of access level 2 and above, all the time, would have the details [2, true] stored.

A website accessible to users of access level 3 and above, only outside of work hours, would have the details [3, false] stored.

(a)

State the name of a data structure that could be used to store a single site’s details.

[1]
Reveal mark scheme Mark scheme for question 5(a)
(b)
Figure for question 5 Figure for question 5
[1]
Reveal mark scheme Mark scheme for question 5(b)
(c)
Figure for question 5 Figure for question 5
[5]
Reveal mark scheme Mark scheme for question 5(c)
(d)

A flaw with the current hash function is it tends to generate lots of collisions (addresses that compute to the same hash). Below is a diagram of part of the hash table. The address www.rnd.com with details [2, true] is being added to the hash table.

Explain how a hash table can be used to handle collisions, referring to the example below.

227
228www.ocr.org.uk : [1, true]
229
230www.ppf.nz : [2, false]
231
232www.ntf.biz : [4, true]
234
235
[4]
Reveal mark scheme Mark scheme for question 5(d)
(e)

The hash function is changed so there are no longer high numbers of collisions.

During busy periods the firewall is expected to check several addresses a second. It is anticipated that roughly 10 new addresses will be added to a whitelist (list of acceptable addresses) each day.

There is a debate as to whether a hash table (with the new hash function) is the best approach, or if the whitelist would be better stored in a linked list.

*Discuss whether a hash table or linked list is better to store acceptable websites. You should compare how each structure can be searched and has data added and come to a

recommendation as to which is better for the whitelist.

[12]
Reveal mark scheme Mark scheme for question 5(e)

Computer systems June 2019, Question 8 10 marks

Also involves Arithmetic operators

Figure for question 8
(a)

State the output of the program when the number 30 is entered.

[1]
Reveal mark scheme Mark scheme for question 8(a)
(b)

State the most suitable data type of the variable count

[1]
Reveal mark scheme Mark scheme for question 8(b)
(c)

State the data type of the result of the expression (count*num)<=100

[1]
Reveal mark scheme Mark scheme for question 8(c)
(d)

State the data type of the result of the expression

str(num) + " goes into 100 " + str(count) + " times."

[1]
Reveal mark scheme Mark scheme for question 8(d)
(e)

Write extra code so the program also displays the remainder.

[2]
Reveal mark scheme Mark scheme for question 8(e)
(f)

The program is compiled. The first stage is Lexical Analysis.

Referring to examples in the code in Fig. 8.1, explain what happens in Lexical Analysis.

[3]
Reveal mark scheme Mark scheme for question 8(f)
(g)

State the name of the stage of compilation that directly follows Lexical Analysis.

[1]
Reveal mark scheme Mark scheme for question 8(g)

Algorithms and programming June 2019, Question 1 17 marks

Also involves Stacks and queues

The temperatures of an ocean are input into a computer system. They are recorded, and will be accessed, in the order in which they arrive. The data for one week is shown:

5, 5.5, 5, 6, 7, 6.5, 6

(a)

The data is to be stored in a data structure. The programmer stores the data in a queue.

Explain why a queue is used instead of a stack.

[2]
Reveal mark scheme Mark scheme for question 1(a)
(b)

The data is processed. After processing, the value for the first day is stored as 0. The value for each following day is stored as an increase, or decrease, from the first day.

For example: if the first day was 7, the second was 6 and the third was 9, after processing it would be stored as 0, –1, 2.

(b)(i)

The queue uses dequeue() to return the first element of the queue.

dequeue() is a function.

Explain why dequeue() is a function, not a procedure.

[1]
Reveal mark scheme Mark scheme for question 1(b)(i)
(b)(ii)
Figure for question 1
[3]
Reveal mark scheme Mark scheme for question 1(b)(ii)
(b)(iii)

The contents of processedData are shown.

Figure for question 1

The data needs to be sorted into ascending order.

Explain how a bubble sort algorithm sorts data. Use the current contents of processedData in your explanation.

[5]
Reveal mark scheme Mark scheme for question 1(b)(iii)
(b)(iv)
Figure for question 1 Figure for question 1 Figure for question 1
[6]
Reveal mark scheme Mark scheme for question 1(b)(iv)

Computer systems June 2018, Question 8 17 marks

A student writes a program to apply a symmetric encryption algorithm to work on messages of up to 25 ASCII characters.

(a)

Describe what is meant by the term ‘ASCII’.

Figure for question 8
[2]
Reveal mark scheme Mark scheme for question 8(a)
(b)

The encryption algorithm works in the following way. A message of up to 25 characters (spaces and punctuation are not included) is placed in a 5×5 array. Any leftover spaces are filled with random letters. The message I LOVE COMPUTER SCIENCE becomes:

ILOVE
COMPU
TERSC
IENCE
TOWRM

The key is a sequence of ten numbers. In this example we will use 1 2 3 4 5 1 2 3 4 5. The first 5 numbers state how many spaces the rows 0 to 4 must be rotated right.

A key with the first 5 digits 1 2 3 4 5 would result in

EILOV
PUCOM
RSCTE
ENCEI
TOWRM

The next 5 digits state how many spaces down the columns 0 to 4 should be rotated.

Applying the last 5 digits 1 2 3 4 5 to the grid above would give

TNCOV
EOCTM
PIWEE
RULRI
ESCOM

Part of the pseudocode for the algorithm is written below.

Figure for question 8

Show the result of running the algorithm on the grid and key below.

KEY: 3 3 3 3 3 1 1 1 1 1

TOPSE
CRETM
ESSAG
EYRPL
UOGGQ

Grid after only the rows are shifted:

Figure for question 8

Grid after columns have also been shifted:

Figure for question 8
[2]
Reveal mark scheme Mark scheme for question 8(b)
(c)

Write the procedure shiftRow.

Figure for question 8
[4]
Reveal mark scheme Mark scheme for question 8(c)
(d)

*Modern encryption is much stronger than the method described in the first part of this question. Discuss the impact of modern encryption on society. You should refer to:

• The importance of asymmetric encryption and how it differs from symmetric encryption.

• Different circumstances in which symmetric and asymmetric encryption may be used.

Figure for question 8
[9]
Reveal mark scheme Mark scheme for question 8(d)

Computer systems June 2017, Question 7 15 marks

A web forum stores all its content in a database.

(a)

The forum stores details of its users in the table called Users. An extract of Users is shown

Figure for question 7

Describe what is meant by the term ‘primary key’, giving an example from the table above.

[2]
Reveal mark scheme Mark scheme for question 7(a)
(b)

The user’s password is passed to a function that generates a hash and the result is stored in passwordHash.

(b)(i)

Describe what is meant by the term ‘hash’.

[1]
Reveal mark scheme Mark scheme for question 7(b)(i)
(b)(ii)

Describe one advantage to storing the password as a hash.

[2]
Reveal mark scheme Mark scheme for question 7(b)(ii)
(c)

Write an SQL statement to get just the passwordHash and locked values of the user Apollo.

[3]
Reveal mark scheme Mark scheme for question 7(c)
(d)

Sometimes users can have their accounts locked if they behave inappropriately. When this is the case the locked field is set to 1 rather than 0.

Write an SQL statement that locks the account of the user Hades

[3]
Reveal mark scheme Mark scheme for question 7(d)
(e)

The function checkAccess takes in the password the user has entered (givenPassword along with the password hash (passwordHash) and locked value (locked).

passwordHash and locked have already been extracted from the database before being passed to the function. It should return the value true if a user should be allowed access to a system and false if they aren’t.

Your function should make use of the pre-written function hash() which takes in a string and returns the hash of that string.

e.g.

hash("Hello") returns f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0

Complete the function checkAccess.

function checkAccess(givenPassword, passwordHash, locked)

endfunction

[4]
Reveal mark scheme Mark scheme for question 7(e)

Computer systems June 2017, Question 10 22 marks

Also involves String manipulation

A software development team is writing a word game.

The team is using Rapid Application Development.

(a)
Figure for question 10
[4]
Reveal mark scheme Mark scheme for question 10(a)
(b)

Players are given 10 random letters and asked to find the largest word they can make from those letters. Each letter can only be used once. The length of the word determines the number of points awarded. e.g. a word with 6 letters would mean 6 points are awarded.

The function validateAnswer takes in the randomLetters as an array of letters and the player’s as a string. It then checks if the word the player has entered only contains letters from the 10 random letters with each letter being used only once. (At this stage the program doesn’t check if the answer provided is an actual word.) It then returns a score, out of 10, for a valid word or 0 for an invalid word.

Example

If the random letters are

OPXCMURETN

The word COMPUTER returns 8

Whereas

The word POST returns 0 (there is no S in the random letters).

And

The word RETURN returns 0 (there is only one R in the random letters).

Complete the function validateAnswer

function validateAnswer(answer, randomLetters[])

endFunction

[6]
Reveal mark scheme Mark scheme for question 10(b)
(c)

Code is to be added to check if the word is an actual English word. All English words are stored in a binary search tree.

Give one advantage of storing the words in a binary search tree over an array.

[1]
Reveal mark scheme Mark scheme for question 10(c)
(d)

The software team use a prebuilt library to create the Graphical User Interface.

(d)(i)

Give two advantages to the software team of using a library.

[2]
Reveal mark scheme Mark scheme for question 10(d)(i)
(d)(ii)

* The program is compiled. Explain the process of compilation including how code from the library becomes part of the finished program, justifying why each stage is necessary.

[9]
Reveal mark scheme Mark scheme for question 10(d)(ii)

Report a problem with a question on this page
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Memes

Certified Computer Science memes. Peer-reviewed by nobody.

Laugh now. Cry in the exam hall later. Then come back and do a past paper.

Write a proper algorithm
Write ‘sort it’ and leave
Me on the 6-mark pseudocode question
Debugging with print statements
Using a trace table
Knowing the difference between = and ==
Explaining recursion by explaining recursion
Code enlightenment, ranked

Mum 💖

can you fix the wifi since you do computers 🥰

that's not what computer science is

so that's a no then

📱 Screen time this week · Discord8h 2m

Turned it off and on again

Computer Science starter pack

Laptop with 47 tabs openPython error on line 1Counting binary on fingersThis website
Compiled with zero errors