01 / Algorithms and computational thinkingEvery board
What is an algorithm?
- AA list of the variables used in some code
- BA sequence of steps that completes a task
- CA diagram of the parts inside a computer
- DA program written in a high-level language
Show the answer
Answer: B A sequence of steps that completes a task
An algorithm is a sequence of steps that completes a task. It can be written as a flowchart, in pseudocode or in code. A program is one way of carrying out an algorithm, so the two are not the same thing.
Checked against cdn.sanity.io
02 / Algorithms and computational thinkingEvery board
A team plans a quiz app by splitting it into parts: asking questions, checking answers, keeping score and showing results.
Which principle of computational thinking is the team using?
- AEncryption
- BCasting
- CDecomposition
- DAbstraction
Show the answer
Answer: C Decomposition
Decomposition breaks a big problem into smaller sub-problems, each of which can be solved, and even split again, on its own. Smaller parts are easier to write and test, and different people can work on them.
Checked against cdn.sanity.io
03 / Algorithms and computational thinkingEvery board
Abstraction means:
- Aremoving detail that is not needed for the problem
- Bwriting code in a low-level language
- Cbreaking a problem into smaller parts
- Ddeleting the lines of code that have errors
Show the answer
Answer: A removing detail that is not needed for the problem
Abstraction removes unnecessary detail so you can focus on what matters to the problem. It is about the problem, not about deleting lines of code, which is a mistake examiners often see.
Checked against cdn.sanity.io
04 / Algorithms and computational thinkingEvery board
A map of a train network shows the stations in the right order and where lines meet, but not real distances, streets or buildings.
Which principle of computational thinking does this map show?
- AValidation
- BIteration
- CDecomposition
- DAbstraction
Show the answer
Answer: D Abstraction
The map keeps only what a traveller needs, the order of stations and where lines meet, and leaves out the rest. Removing unneeded detail like this is abstraction.
Checked against ocr.org.uk
05 / Algorithms and computational thinkingOCR
Working out the steps needed to solve a problem, and the order they go in, is called:
- Acasting
- Babstraction
- Calgorithmic thinking
- Ddecomposition
Show the answer
Answer: C algorithmic thinking
OCR names three principles of computational thinking: abstraction, decomposition and algorithmic thinking. Algorithmic thinking means identifying the steps that solve a problem and the order they must go in.
Checked against ocr.org.uk
06 / Algorithms and computational thinkingEvery board
An app asks for the length and width of a room, multiplies them together and shows the floor area.
Which of these is the process?
- AMultiplying the length by the width
- BTyping in the length
- CTyping in the width
- DShowing the floor area on screen
Show the answer
Answer: A Multiplying the length by the width
Inputs are data going in (the length and width), processing is what is done to them (multiplying), and outputs are the results given out (the area shown). Exam questions often ask you to name each one.
Checked against cdn.sanity.io
07 / Algorithms and computational thinkingEvery board
In a flowchart, which shape shows a decision, such as checking whether a score is over 50?
- AA diamond
- BA rectangle
- CA rounded rectangle
- DA parallelogram
Show the answer
Answer: A A diamond
A decision is drawn as a diamond with one way in and two ways out, usually labelled Yes and No. It is how a flowchart shows selection, and a loop is drawn as a decision with an arrow leading back up.
Checked against ocr.org.uk
08 / Algorithms and computational thinkingEvery board
Which flowchart shape is used to input or output data?
- AA diamond
- BA plain rectangle
- CA rounded rectangle
- DA parallelogram
Show the answer
Answer: D A parallelogram
Input and output, such as “Enter name” or “Display total”, go in a parallelogram. Calculations and other processing go in a plain rectangle.
Checked against ocr.org.uk
09 / Algorithms and computational thinkingEvery board
Which flowchart shape marks the start or the end?
- AA diamond
- BA plain rectangle
- CA rounded rectangle
- DA parallelogram
Show the answer
Answer: C A rounded rectangle
Start and Stop go in a terminal symbol, a rectangle with rounded ends. A process, such as a calculation, goes in a plain rectangle.
Checked against ocr.org.uk
10 / Algorithms and computational thinkingOCR and Edexcel
In a flowchart, a rectangle with an extra line down each side shows:
- Aa sub program
- Bthe start
- Ca decision
- Dan input
Show the answer
Answer: A a sub program
OCR and Edexcel both draw a sub program (Edexcel says pre-defined subprogram), a call to a procedure or function, as a rectangle with an extra line down each side. It tells the reader that those steps are set out somewhere else.
Checked against ocr.org.uk
11 / Algorithms and computational thinkingEvery board
Why do programmers often write pseudocode before writing real code?
- ATo translate the code into machine code
- BBecause a computer can run pseudocode directly
- CTo plan the logic without worrying about exact syntax
- DBecause pseudocode runs faster than real code
Show the answer
Answer: C To plan the logic without worrying about exact syntax
Pseudocode sets out an algorithm in structured, code-like English. It is not tied to one language and cannot be run, so you can get the logic right first and then turn it into real code.
Checked against qualifications.pearson.com
12 / Algorithms and computational thinkingEvery board
What is a trace table used for?
- AListing the files saved on a computer
- BStoring data in a database
- CRecording the value of each variable as an algorithm runs
- DDrawing the parts of a flowchart
Show the answer
Answer: C Recording the value of each variable as an algorithm runs
A trace table has a column for each variable (and often the output) and a row for each change. Working through it line by line shows what the code does and where it goes wrong, which helps find logic errors.
Checked against ocr.org.uk
13 / Algorithms and computational thinkingOCR
A structure diagram shows:
- Aevery variable and its data type
- Bthe order of steps with decisions and loops
- Cthe inputs and outputs of a logic gate
- Da problem broken down into smaller parts
Show the answer
Answer: D a problem broken down into smaller parts
A structure diagram is a top-down chart: the whole problem at the top, split into sub-problems below, which can be split again. It is a picture of decomposition, and OCR asks pupils to draw one.
Checked against ocr.org.uk
14 / Algorithms and computational thinkingEvery board
How does a linear search find an item?
- AIt checks each item in turn from the start
- BIt sorts the list first, then jumps to the item
- CIt checks the middle item and halves the list
- DIt compares neighbours and swaps them
Show the answer
Answer: A It checks each item in turn from the start
A linear search starts at the first item and checks each one in turn until it finds the target or reaches the end of the list. It is simple and works on any list, sorted or not.
Checked against cdn.sanity.io
15 / Algorithms and computational thinkingEvery board
Which is true about a linear search?
- AIt always checks the middle item first
- BIt works whether or not the list is sorted
- CIt only works on lists of numbers
- DIt only works on a sorted list
Show the answer
Answer: B It works whether or not the list is sorted
Because a linear search checks every item in order, the list does not need to be sorted. Saying it needs sorted data is a common mistake; that is true of a binary search.
Checked against cdn.sanity.io
16 / Algorithms and computational thinkingEvery board
What must be true of a list before a binary search can be used on it?
- AIt must have an even number of items
- BIt must be sorted
- CIt must contain only numbers
- DIt must have fewer than 100 items
Show the answer
Answer: B It must be sorted
A binary search throws away half the list each time by deciding which side the target must be on. That only works if the list is in order, so sorted data is a pre-requisite.
Checked against ocr.org.uk
17 / Algorithms and computational thinkingEvery board
In a binary search, what happens if the middle item is the target?
- AThe left half is searched next
- BThe right half is searched next
- CThe list is sorted again
- DThe search stops: the item is found
Show the answer
Answer: D The search stops: the item is found
Each step looks at the middle item. If it is the target, the search stops; if the target is smaller, the upper half is discarded; if larger, the lower half. This repeats until the item is found or nothing is left.
Checked against cdn.sanity.io
18 / Algorithms and computational thinkingEvery board
A list of names in alphabetical order: Amir, Beth, Chloe, Dev, Ella, Femi, Grace.
Can a binary search be used to find Femi in this list?
- ANo, names can only be found with a bubble sort
- BYes, because the names are in order
- CNo, the list has an odd number of items
- DNo, binary search only works on numbers
Show the answer
Answer: B Yes, because the names are in order
Binary search works on any data that can be put in order, including words in alphabetical order. Thinking it only works on numbers is a common exam mistake.
Checked against cdn.sanity.io
19 / Algorithms and computational thinkingEvery board
Why is a binary search usually quicker than a linear search on a long sorted list?
- AIt sorts the list as it goes
- BIt halves the items left to check at every step
- CIt starts at the end of the list
- DIt checks every item twice to be sure
Show the answer
Answer: B It halves the items left to check at every step
A binary search discards half of what is left each time, so even a huge sorted list needs few checks. A linear search is simpler and works on unsorted data, so it suits short or unsorted lists, where sorting first would cost more time.
Checked against cdn.sanity.io
20 / Algorithms and computational thinkingEvery board
In the worst case, how many items does a linear search check in a list of n items?
- AAll n items
- BHalf of the items
- COnly the first item
- DOnly the middle item
Show the answer
Answer: A All n items
If the target is the last item, or is not there at all, a linear search has to look at every item. That is why it is slow on long lists, while a binary search on sorted data checks far fewer.
Checked against qualifications.pearson.com
21 / Algorithms and computational thinkingEvery board
How does a bubble sort work?
- AIt checks the middle item and discards half the list
- BIt splits the list into single items, then merges them in order
- CIt inserts each item into a sorted part of the list
- DIt compares neighbouring items and swaps them if out of order
Show the answer
Answer: D It compares neighbouring items and swaps them if out of order
A bubble sort goes through the list comparing each pair of neighbours and swapping them if they are in the wrong order. Each run through the list is a pass, and passes repeat until the list is sorted.
Checked against cdn.sanity.io
22 / Algorithms and computational thinkingEvery board
Put the steps of a bubble sort in order.
- ACarry on to the end of the list to finish the pass
- BCompare the first two items
- CRepeat passes until a pass makes no swaps
- DMove along one place and compare the next pair
- ESwap them if they are in the wrong order
Show the answer
The right order:
- Compare the first two items
- Swap them if they are in the wrong order
- Move along one place and compare the next pair
- Carry on to the end of the list to finish the pass
- Repeat passes until a pass makes no swaps
One pass compares every neighbouring pair from the start of the list to the end, swapping where needed. The sort is finished when a whole pass makes no swaps, because then every pair is in order.
Checked against ocr.org.uk
23 / Algorithms and computational thinkingEvery board
How does a bubble sort know the list is sorted?
- AThe first two items are in order
- BThe middle item matches the target
- CEvery item has been moved once
- DA whole pass makes no swaps
Show the answer
Answer: D A whole pass makes no swaps
In each pass the largest unsorted item is carried along to its final place, so after the first pass the biggest value is at the end. When a pass makes no swaps, every pair is in order and the sort can stop.
Checked against cdn.sanity.io
24 / Algorithms and computational thinkingEvery board
Which is an advantage of a bubble sort?
- AIt only works on sorted lists
- BIt never needs more than one pass
- CIt is always the quickest sort, however long the list is
- DIt is simple to write and needs little extra memory
Show the answer
Answer: D It is simple to write and needs little extra memory
A bubble sort is easy to code and sorts the list in place, so it needs little extra memory. But it may need many passes, so it is slow on large lists. On a list that is already sorted it can stop after one pass.
Checked against cdn.sanity.io
25 / Algorithms and computational thinkingEvery board
How does a merge sort put items in order?
- AIt checks the middle item and discards half
- BIt joins all the lists together first, then sorts the whole result
- CIt splits the list up, then merges the parts back in order
- DIt swaps neighbouring items over many passes
Show the answer
Answer: C It splits the list up, then merges the parts back in order
A merge sort splits the list until every part has one item, and a list of one is already sorted. It then merges pairs of lists, comparing as it goes so each merged list is in order, until one sorted list remains.
Checked against cdn.sanity.io
26 / Algorithms and computational thinkingEvery board
Two sorted lists are being merged: [3, 8, 9] and [2, 5, 10].
How is the next item for the merged list chosen?
- ATake every item from the first list, then every item from the second
- BCompare the front item of each list and take the smaller
- CTake items from each list in turn
- DTake the largest item from either list
Show the answer
Answer: B Compare the front item of each list and take the smaller
When merging, compare the first item of each list, move the smaller one to the new list, and repeat. Here 2 goes first, then 3, then 5. Joining the lists first and sorting afterwards is a common wrong description.
Checked against ocr.org.uk
27 / Algorithms and computational thinkingEvery board
Which is an advantage of a merge sort over a bubble sort?
- AIt uses less memory
- BIt is simpler to write
- CIt does not need to compare items
- DIt is usually much faster on large lists
Show the answer
Answer: D It is usually much faster on large lists
A merge sort is usually much quicker than a bubble sort on large lists. The cost is memory, because it creates new lists while splitting and merging, and it is harder to code. A bubble sort is simpler and sorts in place.
Checked against cdn.sanity.io
28 / Algorithms and computational thinkingOCR
How does an insertion sort work?
- AIt compares the middle item with a target
- BIt keeps splitting the list into halves, then merges them back in order
- CIt swaps neighbours until a pass makes no swaps
- DIt takes each item in turn and puts it in place in a sorted part
Show the answer
Answer: D It takes each item in turn and puts it in place in a sorted part
An insertion sort builds a sorted part at the start of the list. Each new item is compared with the sorted items, moving left, and slotted into its correct place. It is on the OCR specification only.
Checked against ocr.org.uk
29 / Algorithms and computational thinkingOCR
When does an insertion sort work well?
- AOn small lists or lists that are nearly sorted
- BOn huge lists in a completely random order
- COnly after a binary search has been run
- DOnly on lists with an even number of items
Show the answer
Answer: A On small lists or lists that are nearly sorted
If a list is nearly sorted, each item only moves a short way, so an insertion sort is quick and needs little extra memory. On large, jumbled lists it slows down, and a merge sort is usually faster.
Checked against ocr.org.uk
30 / Algorithms and computational thinkingEvery board
temp = names[0]
names[0] = names[1]
names[1] = temp
Why is the variable temp needed when swapping two items?
- ATo keep a count of how many swaps the sort has made so far
- BSo the first value is not lost when it is overwritten
- CBecause arrays cannot hold strings
- DSo the code runs faster
Show the answer
Answer: B So the first value is not lost when it is overwritten
If you copy b into a straight away, the old value of a is lost. Copying it into temp first keeps it safe. Temp holds the value, not the position, which is a mistake examiners often see.
Checked against ocr.org.uk
31 / Algorithms and computational thinkingEvery board
Two sorting algorithms are run on the same list. Which is a fair way to compare their efficiency?
- ASee which one was written first
- BCount the lines of code in each
- CCount the comparisons each one makes
- DCompare the length of their variable names
Show the answer
Answer: C Count the comparisons each one makes
Efficiency is about how much work an algorithm does, so compare the time taken, the number of comparisons or the passes through a loop on the same data. Edexcel also asks about memory used. Line counts and names say nothing about speed.
Checked against qualifications.pearson.com
32 / Algorithms and computational thinkingEvery board
A library has 500,000 book records sorted by ID number. Which search finds one ID fastest?
- ABubble sort
- BBinary search
- CMerge sort
- DLinear search
Show the answer
Answer: B Binary search
A binary search needs sorted data and is far quicker on long lists, halving the work each step. For a short unsorted list a linear search is simplest; sorting first would take longer than checking eight items.
Checked against cdn.sanity.io
33 / Algorithms and computational thinkingEvery board
for i = 0 to items.length - 2
if items[i] > items[i + 1] then
temp = items[i]
items[i] = items[i + 1]
items[i + 1] = temp
endif
next i
This code is part of which standard algorithm?
- ABubble sort
- BBinary search
- CMerge sort
- DLinear search
Show the answer
Answer: A Bubble sort
Comparing items[i] with its neighbour items[i + 1] and swapping when they are out of order is the heart of a bubble sort. One run of the loop is one pass, and the sort repeats passes until none makes a swap.
Checked against ocr.org.uk
34 / Algorithms and computational thinkingEvery board
found = False
for i = 0 to names.length - 1
if names[i] == target then
found = True
endif
next i
Which standard algorithm does this code carry out?
- ABubble sort
- BBinary search
- CMerge sort
- DLinear search
Show the answer
Answer: D Linear search
The loop checks each name from position 0 to the end and sets found to True on a match. Checking items one by one like this is a linear search, so the list does not need to be in order.
Checked against ocr.org.uk
35 / Algorithms and computational thinkingEduqas
Some code keeps reading test scores and adding them up until the user types -1.
What is the -1 called?
- AA global variable
- BA parameter
- CA rogue value
- DA constant
Show the answer
Answer: C A rogue value
A rogue value, also called a sentinel, is a special value that cannot be real data, used to tell a loop to stop. A score of -1 is impossible, so it safely marks the end of the input.
Checked against eduqas.co.uk