0% found this document useful (0 votes)
35 views

Algorithms Revision Pack

Uploaded by

medwindmat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Algorithms Revision Pack

Uploaded by

medwindmat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

2.

1 Algorithms Topic Revision Pack Name: _______________________________

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.

i. Define the term abstraction.

[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

A Book new appointment

B Check attendance of child

C Update personal details

D View appointments on-screen

E Log out of the system

F Print a paper copy of appointments

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

stocklevel = input("Enter stock level")


if stocklevel >= 5 or =< 25 then
print(Not in demand)
else
print(In demand)
endif

The program contains syntax and logic errors.

Refine the program to correct the errors and write the refined version of the program.

You must use either:

• OCR Exam Reference Language, or


• A high-level programming language that you have studied

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

An example for one student is shown:


array appointments = ["Miss E", "", "Mr C", "Mr B", ""]

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.

Define the term logic error.

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

01 num = input(“enter a number”)


02 if num MOD 2 >= 0 then

03 print(“even”)
04 else

05 pritn(“odd”)
06 endif

The program contains a syntax error on line 05.

i. State what is meant by a syntax error.

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

Complete the trace table to test this program.

x y output

[4]

8(a). The algorithm for one section of a vending machine program is shown in pseudocode.

if money >= price then


venditem()
giveChange(money – price)
else
print("Error – not enough money inserted")
endif

i. Give the identifier of one variable used in the algorithm.

[1]

ii. State how many parameters are passed into the giveChange() subroutine.

[1]

(b). A vending machine has the following options available.

Item code Item name Price


A1 Crisps, bacon flavour £0.75

A2 Crisps, salted £0.75

B1 Chocolate bar £0.90

C1 Apple pieces £0.50

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.

Draw the vending machine algorithm in the part above as a flowchart.


[5]

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

Function call Returned value

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.

i. State why this function call will produce an error.

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

Complete the function calculate

function calculate(.................................................., number)

if measurement = = "gigabytes" then

value = number * 1024 * 1024 * 1024 * 8

elseif measurement = = ".................................................." then

value = number * 1024 * 1024 * 8

elseif measurement = = ".................................................." then

value = number * 1024 * 8

elseif measure = = "bytes" then

value = number * ..................................................

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.

A list of valid discount codes is shown below.

[NIC12B, LOR11S, STU12M, VIC08E, KEI99M, WES56O, DAN34S]

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.

i. The grades for one student are shown:

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.

Your answer must refer to the grades provided.

[4]

ii. Explain how a binary search would determine that a value does not appear in a given array.

[2]

iii. Give one advantage of a binary search over a linear search.

[1]

END OF QUESTION PAPER

You might also like