You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson provides comprehensive exam practice for the Algorithms topic, covering the key content from OCR J277 Section 2.2 that appears on Paper 2: Computational Thinking, Algorithms and Programming. This lesson brings together searching algorithms, sorting algorithms, trace tables, and algorithm design.
The OCR J277 Paper 2 exam is worth 80 marks and lasts 1 hour 30 minutes. The algorithms section typically accounts for approximately 15–25 marks. Questions range from 1-mark recall questions to 6-mark extended response questions.
Common question types include:
| Question Type | Typical Marks | What You Need to Do |
|---|---|---|
| Define/State | 1–2 marks | Give a precise definition (e.g. "What is an algorithm?") |
| Describe | 2–4 marks | Explain how an algorithm works step by step |
| Compare | 3–4 marks | Identify similarities and differences between algorithms |
| Trace table | 3–5 marks | Complete a trace table for given pseudocode |
| Write/Complete pseudocode | 3–6 marks | Write or complete an algorithm in pseudocode/Python |
| Evaluate/Recommend | 4–6 marks | Justify which algorithm is best for a given scenario |
Question: Define the term "algorithm" and give one reason why algorithms are used in program development.
Model Answer: An algorithm is a step-by-step set of instructions designed to solve a specific problem or complete a task (1 mark). Algorithms are used in program development to plan the solution before writing code, ensuring the logic is correct and allowing programmers to identify potential issues early (1 mark).
Question: The array data contains: [12, 5, 8, 3, 15, 7]. Trace the following algorithm when searching for the value 15.
target = 15
for i = 0 to data.length - 1
if data[i] == target then
print("Found at " + str(i))
endif
next i
Model Answer:
| i | data[i] | data[i] == 15? | Output |
|---|---|---|---|
| 0 | 12 | No | |
| 1 | 5 | No | |
| 2 | 8 | No | |
| 3 | 3 | No | |
| 4 | 15 | Yes | "Found at 4" |
| 5 | 7 | No |
Question: Describe how binary search would find the value 42 in the sorted list [10, 20, 30, 42, 50, 60, 70].
Model Answer:
(In this case the target happens to be the middle element. For a harder example where multiple steps are needed, always show low, high, mid at each step.)
Question: A company needs to sort a database of 100,000 customer records. Compare the suitability of bubble sort and merge sort for this task.
Model Answer:
OCR Exam Tip: For comparison questions, always state the time complexity with numbers, explain the practical impact, and consider both time and space. A balanced answer that acknowledges drawbacks of your recommended algorithm will score higher.
Question: Write an algorithm in pseudocode that takes a list of 10 test scores and finds the highest score. Output the highest score.
Model Answer:
scores = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i = 0 to 9
scores[i] = int(input("Enter score: "))
next i
highest = scores[0]
for i = 1 to 9
if scores[i] > highest then
highest = scores[i]
endif
next i
print("Highest score is: " + str(highest))
Python equivalent:
scores = []
for i in range(10):
scores.append(int(input("Enter score: ")))
highest = scores[0]
for i in range(1, 10):
if scores[i] > highest:
highest = scores[i]
print("Highest score is:", highest)
Question: Show the state of the list [7, 3, 5, 1] after each complete pass of bubble sort.
Model Answer:
Pass 1: Compare 7&3 (swap), 7&5 (swap), 7&1 (swap) → [3, 5, 1, 7]
Pass 2: Compare 3&5 (no swap), 5&1 (swap) → [3, 1, 5, 7]
Pass 3: Compare 3&1 (swap) → [1, 3, 5, 7]
Pass 4: No swaps — list is sorted. Final: [1, 3, 5, 7]
| Topic | Can I... |
|---|---|
| Algorithms | Define an algorithm and explain why they are used? |
| Linear search | Describe, write in pseudocode, and trace it? |
| Binary search | Describe, write in pseudocode, and trace it? State it needs sorted data? |
| Bubble sort | Describe, write in pseudocode, and show passes? |
| Merge sort | Describe the divide and merge phases? |
| Insertion sort | Describe how elements are inserted into the sorted portion? |
| Comparing algorithms | Compare time complexity, space complexity, and suitability? |
| Trace tables | Complete a trace table accurately for any given pseudocode? |
OCR Exam Tip: Before the exam, practise completing trace tables under timed conditions. Many students understand the algorithms but make careless errors under time pressure. The more you practise, the fewer mistakes you will make.
Question: Show the stages of a merge sort applied to the list [8, 2, 5, 1, 7, 3]. Show both the divide phase and the merge phase.
Model Answer:
Divide phase:
graph TD
N0["[8, 2, 5, 1, 7, 3]"] --> N1["[8, 2, 5]"]
N0 --> N2["[1, 7, 3]"]
N1 --> N3["[8]"]
N1 --> N4["[2, 5]"]
N2 --> N5["[1]"]
N2 --> N6["[7, 3]"]
N4 --> N7["[2]"]
N4 --> N8["[5]"]
N6 --> N9["[7]"]
N6 --> N10["[3]"]
Merge phase:
Final sorted list: [1, 2, 3, 5, 7, 8].
Question: Complete the trace table for the algorithm below when num = 12.
num = 12
count = 0
i = 1
while i <= num
if num MOD i == 0 then
count = count + 1
endif
i = i + 1
endwhile
print(count)
Model Answer:
| i | num MOD i | Divisor? | count |
|---|---|---|---|
| 1 | 0 | Yes | 1 |
| 2 | 0 | Yes | 2 |
| 3 | 0 | Yes | 3 |
| 4 | 0 | Yes | 4 |
| 5 | 2 | No | 4 |
| 6 | 0 | Yes | 5 |
| 7 | 5 | No | 5 |
| 8 | 4 | No | 5 |
| 9 | 3 | No | 5 |
| 10 | 2 | No | 5 |
| 11 | 1 | No | 5 |
| 12 | 0 | Yes | 6 |
Output: 6 (the number of divisors of 12: 1, 2, 3, 4, 6, 12).
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.