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. Algorithms in pseudocode, flowcharts and reference language

OCR A Level Computer Science

Topic questions Algorithms Algorithms in pseudocode, flowcharts and reference language

Algorithms in pseudocode, flowcharts and reference language

10 questions · 178 marks · about 3 hours

Algorithms in pseudocode, flowcharts and reference language questions

OCR H446 Algorithms in pseudocode, flowcharts and reference language 10 questions

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)

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 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