Algorithms Revision Pack
Algorithms Revision Pack
This set of revision questions covers all of topics within 2.1 Algorithms. After you have completed the questions RAG each line from the
sub topic list to identify your strengths and weaknesses.
Revision Material
Scan the QR Code to access a range of revision videos, or notes on all areas of the topic.
If you watch videos or read notes, you need to do something with the information.
You need to process it, so it sticks in your long term memory. Doing any of the following
activities will help this process:
• Take notes and revisiting it
• Make a mindmap
• Create or use premade flash cards on the topic
• Answer exam question
Youtube CSNewsbs
• Answer diagnostic multiple choice questions
1. Taylor is writing an algorithm to record the results of an experiment. She needs to be able to enter a numeric value which is
added to a total which initially starts at 0. Every time she enters a value, the total is output. The algorithm repeats until the
total is over 100.
Taylor used computational thinking techniques to develop the algorithms.
Give two computational thinking techniques that Taylor has used, describing how they have been used.
1.
2.
[4]
2. A car dealership uses a computer system to record details of the cars that it has for sale. Each car has a make, model, age and
number of miles driven.
Each car is given a star rating of 1 to 5, based on the age of the car and the number of miles it has been driven. This ratin g is
recorded in the computer system.
[1]
ii. Give one example of how abstraction has been used in the design of this star rating system.
[1]
iii. Explain how authentication could be used as part of the defensive design considerations for this computer system.
[2]
3. A school uses a mobile phone app to allow parents to book appointments for parents’ evenings.
Parents must log in before they can use the system. They then choose to book a new appointment, view all appointments already
made or update their personal details. If parents choose to view their appointments, they can either view them on -screen or print
them off.
A structure diagram has been used to design the mobile phone app.
Write one letter from the following table in each space to complete the structure diagram.
Letter Task
[4]
4. OCR Tech is an online shop that sells electronics such as TVs and game consoles.
An item is classified as "In demand" if OCR Tech have between 5 and 25 inclusive in stock.
A program is written that allows the user to input the current stock level and output whether the item is in demand or not.
Refine the program to correct the errors and write the refined version of the program.
[5]
5. A school uses a mobile phone app to allow parents to book appointments for parents’ evenings.
Parents must log in before they can use the system. They then choose to book a new appointment, view all appointments already
made or update their personal details. If parents choose to view their appoin tments, they can either view them on-screen or print them
off.
At the parents’ evening, each parent can book up to five appointments with teachers.
Appointments for one student are stored in a one-dimensional array with the identifier appointments.
In the array, each element is either the name of a teacher or an empty string where no appointment has been made.
The following code shows an algorithm to count up how many empty slots remain in the array and output this value.
01 for i = 0 to 4
02 empty = 0
03 if appointments[i] == "" then
04 empty = empty + 1
05 endif
06 next i
07 print("empty")
i. The algorithm contains logic errors.
[1]
Identify the line number of two logic errors in the code above and explain why each is an error.
Logic error 1
Explanation
Logic error 2
Explanation
[4]
6. Louise writes a program to work out if a number entered by the user is odd or even. Her first attempt at this program is shown.
03 print(“even”)
04 else
05 pritn(“odd”)
06 endif
[1]
ii. Give a corrected version of line 05 that fixes the syntax error.
[1]
7 The following program uses a condition-controlled loop.
. x = 15
y = 0
while x > 0
y = y + 1
x = x – y
endwhile
print(y)
x y output
[4]
8(a). The algorithm for one section of a vending machine program is shown in pseudocode.
[1]
ii. State how many parameters are passed into the giveChange() subroutine.
[1]
C2 Raisins £0.85
Users insert coins into the vending machine and then enter the two character item code of their selection. If the user has in serted
enough money, the vending machine will release the chosen item and output any change required. If the user enters an invalid
item code then a suitable error message is displayed.
(c). When writing the program for the vending machine, maintainability was considered.
i. Identify two ways that the program in the part above has been made more maintainable.
[2]
ii. Give one additional way that the maintainability of the program can be improved.
[1]
9(a). OCRBlocks is a game played on a 5 × 5 grid. Players take it in turns to place blocks on the board.
The board is stored as a two-dimensional (2D) array with the identifier gamegrid
Fig. 6.1 shows that players A and B have placed three blocks each so far.
Fig. 6.1
The function checkblock() checks whether a square on the board has been filled. When checkblock(4,2) is called,
the value "A" is returned.
function checkblock(r,c)
if gamegrid[r,c] == "A" or gamegrid[r,c] == "B" then
outcome = gamegrid[r,c]
else
outcome = "FREE"
endif
return outcome
endfunction
Give the returned value when the following statements are called.
checkblock(2,1)
checkblock(3,0)
checkblock(2,3)
[3]
(b). State one feature of checkblock() that shows that it is a function and not a procedure.
[1]
(c). When checkblock(-1,6) is called, an error is produced.
[1]
ii. Describe how validation could be added in to the checkblock() function to stop this error from occurring.
[3]
10. A program is being created to convert the data capacity of a storage device into a different measure.
The function, calculate(), takes the measurement (e.g. gigabytes) and the number (e.g. 2) as two parameters. It then returns
the value in bits. The function returns –1 if an invalid measurement was entered.
else
..................................................
endif
return ..................................................
endfunction
[6]
11. OCR Land is a theme park aimed at children and adults. Entrance tickets are sold online. An adult ticket to OCR Land costs £19.99,
with a child ticket costing £8.99. A booking fee of £2.50 is added to all orders.
i. State one reason why a binary search would not be able to be used with this data.
[1]
ii. Give the name of one searching algorithm that would be able to be used with this data.
[1]
12. A school uses a mobile phone app to allow parents to book appointments for parents’ evenings.
Parents must log in before they can use the system. They then choose to book a new appointment, view all appointments already
made or update their personal details. If parents choose to view their appointments, they can either view them on-screen or print
them off.
Each teacher has the assessment grades for each student. These grades are stored in numerical order.
2 3 4 5 6 7 8
Show the steps that a binary search would take to check whether the student has achieved a grade 7 in any assessment.
[4]
ii. Explain how a binary search would determine that a value does not appear in a given array.
[2]
[1]