Book a lesson
HomeResourcesGCSE Algorithm Cheat Sheet
GCSE Computer Science ยท Revision Tool

GCSE Algorithm Cheat Sheet

Quick reference guide for all sorting and searching algorithms in the OCR GCSE Computer Science specification. Bubble sort, merge sort, linear search, binary search โ€” with pseudocode and worked examples.

Book a sessionBrowse resources

What this covers

Bubble sort โ€” logic, pseudocode, and trace example
Merge sort โ€” how it works and why it is more efficient
Linear search โ€” step by step
Binary search โ€” when to use it and why
Time complexity explained simply

Why algorithms matter in GCSE CS

Algorithms appear on both papers. You need to be able to trace them, identify them from pseudocode, explain how they work, and compare their efficiency. These questions are predictable โ€” preparation pays off.

What the exam asks

Trace a bubble sort through 3 passes. Explain why binary search is faster than linear search for large lists. Write pseudocode for a linear search. These are real exam question types โ€” all covered here.

How to use this page

Read through each algorithm, trace the example, then practise with your own data. Use the cheat sheet as a reference during revision โ€” not as a substitute for understanding.

Linear vs Binary search โ€” side by side

The most commonly examined comparison in GCSE Computer Science.

LINEAR SEARCHCheck every item in order3712194158Searching for 9...Checked: 1,2,3,4,5 itemsโœ“ Found at position 4Worst case: check ALL n itemsO(n)Works on unsorted lists โœ“BINARY SEARCHHalve the search space each step1347891215Sorted: 1,3,4,7,8,9,12,15Step 1: mid=7 โ†’ too low โ†’ right halfStep 2: mid=9 โ†’ found! 2 checksWorst case: logโ‚‚(n) comparisonsO(log n)Requires sorted list !
key termAlgorithmA set of step-by-step instructions to solve a problem
key termTrace tableA table tracking variable values as code runs
key termLinear searchChecks each item in order โ€” O(n)
key termBinary searchHalves the list each step โ€” O(log n)
key termBubble sortSwaps adjacent pairs โ€” O(nยฒ)

Linear vs Binary search โ€” side by side

The most commonly examined comparison in OCR GCSE CS.

LINEAR SEARCHCheck every item in order3712194158Searching for 9... 5 checks neededWorst case: check ALL itemsO(n)โœ“ Works on unsorted listsBINARY SEARCHHalve the search space each step1347891215Sorted. mid=7 โ†’ too low โ†’ right halfmid=9 โ†’ found! Only 2 checksWorst case: logโ‚‚(n) comparisonsO(log n)โš  Requires a sorted list
key termLinear searchO(n) โ€” checks every item
key termBinary searchO(log n) โ€” halves the list each time
key termBubble sortO(nยฒ) โ€” swaps adjacent pairs
key termMerge sortO(n log n) โ€” divide and conquer
key termTrace tableTracks variable values step by step

Bubble Sort

The simplest sorting algorithm and the most commonly examined. Easy to trace but inefficient for large lists.

1
Compare adjacent pairs.
Starting from the left, compare the first two items. If the left one is larger, swap them. Then move one position right.
2
One pass = one large value bubbles to the end.
After one complete pass through the list, the largest value is in its correct final position at the right.
3
Repeat with a shorter list.
On each subsequent pass, you can ignore the last sorted element. The unsorted section shrinks by one each pass.
4
Stop when no swaps occur.
If you complete a pass without making any swaps, the list is sorted. This is the early termination condition.

Worked trace: sort [5, 3, 8, 1]

Pass 1: [3,5,8,1] โ†’ [3,5,8,1] โ†’ [3,5,1,8]    8 is now sorted
Pass 2: [3,5,1,8] โ†’ [3,1,5,8]    5,8 sorted
Pass 3: [1,3,5,8]    No swaps โ€” sorted

Merge Sort

More efficient than bubble sort for large lists. Uses a divide and conquer approach. Harder to trace but appears in higher-grade questions.

1
Divide.
Split the list in half repeatedly until you have individual elements. A list of one item is always sorted.
2
Merge.
Take two sorted sub-lists and merge them by comparing the front elements of each, taking the smaller each time.
3
Repeat until one list.
Keep merging pairs of sorted sub-lists until you have one fully sorted list.

Efficiency comparison

Bubble sort: O(nยฒ) โ€” doubles in steps each time the list doubles. Merge sort: O(n log n) โ€” much more efficient for large datasets. Examiners ask you to explain this difference.

Linear Search

The simplest search algorithm. Works on any list โ€” sorted or unsorted. Slow for large lists.

1
Start at the first element.
Look at the item at position 0.
2
Compare to target.
Does this item match what you are looking for? If yes โ€” found. If no โ€” move to the next item.
3
Repeat until found or end.
Continue moving through each item in order. If you reach the end without finding the target, it is not in the list.
FOR i = 0 TO LENGTH(list) - 1
    IF list[i] = target THEN
        RETURN i  // found at position i
    ENDIF
NEXT
RETURN -1  // not found

Binary Search

Much faster than linear search โ€” but only works on a sorted list. Cuts the search space in half on every step.

1
Find the midpoint.
Calculate the middle index of the current search range.
2
Compare to target.
If the middle item matches, you found it. If the target is smaller, search the left half. If larger, search the right half.
3
Repeat on the correct half.
Each comparison halves the remaining search space. A list of 1,024 items needs at most 10 comparisons.

When to use which

Linear search: use when the list is unsorted, or the list is very small. Binary search: use when the list is sorted โ€” much faster for large datasets.

Want exam technique support for algorithm questions?

Algorithm questions are predictable and markable โ€” with the right method. Miss ICT sessions use worked examples to make every algorithm type feel manageable.

Book a GCSE sessionView algorithms guide

Frequently asked questions

Which sort algorithm is better?

Merge sort is more efficient for large lists. Bubble sort is simpler to understand and trace. OCR asks you to explain the difference โ€” merge sort is O(n log n), bubble sort is O(nยฒ).

Do I need to memorise pseudocode?

You need to be able to write pseudocode for linear and binary search and trace bubble sort. OCR provides their pseudocode reference โ€” use it in your revision.

Can binary search be used on an unsorted list?

No. Binary search only works correctly on a sorted list. This is a common trick question.

Related resources

Full guide

Algorithms Explained

Detailed walkthrough of all algorithm types with trace examples.

Theory

Binary Explained

Data representation โ€” the other main theory topic alongside algorithms.

Foundations

Coding Fundamentals

Variables, loops, and the logic behind pseudocode.

Exam practice

Mock Exam Walkthroughs

Apply your algorithm knowledge to real exam-style questions.

Book a session โ†’
โœ” GCSE examiner ยท โœ” DBS checked