Algorithms
OCR GCSE Computer Science revision on Algorithms. Aligned to the OCR GCSE Computer Science J277 specification. This bank has 8 practice questions on this topic.
Sample questions (3 of 8)
-
Question 1
A LINEAR search works by...
- A) Repeatedly halving the data set
- B) Checking each item one-by-one from start to end
- C) Sorting the list first, then guessing
- D) Comparing in random order
Show answer
Answer: Checking each item one-by-one from start to end
Linear search is simple but slow on big data — up to N comparisons for a list of N items. Doesn't require the list to be sorted. Binary search is faster (log₂N comparisons) but only works on a SORTED list — it keeps halving the search space.
-
Question 2
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- A) Merge sort
- B) Bubble sort
- C) Insertion sort
- D) Quick sort
Show answer
Answer: Bubble sort
On each pass, you compare each adjacent pair and swap if they're out of order. After the first pass, the biggest value is at the end. Repeat until no swaps happen on a full pass. Simple but slow (O(n²)). Compare with merge sort — recursive, O(n log n), much faster on large lists.
-
Question 3
Binary search ONLY works if the data is...
- A) Unsorted
- B) Sorted
- C) All the same value
- D) Stored in a file
Show answer
Answer: Sorted
Binary search: check the middle. If target is bigger, search the upper half; if smaller, search the lower half. Halve until found. Only works because you can decide which HALF to discard at each step — needs ordering. Worst case: log₂N steps. For N = 1 million, that's only ~20 steps (vs up to 1 million for linear).
Want to test yourself on the remaining cards for this topic?
5 more questions on Algorithms — plus mistakes tracking and spaced repetition across the whole Computer Science spec.