OCR GCSE Computer Science (J277) · Paper 2

🧩 Algorithms

Revision notes written to the specification, with examiner tips and the required practicals. Every point here has flashcards in the Stickwise app.

Computational thinking, searching & sorting

An algorithm is a precise sequence of steps for solving a problem. Designing one starts by naming the inputs, processes and outputs, then thinking computationally. Abstraction means dropping irrelevant detail. Decomposition means splitting the problem into smaller parts, often drawn as a structure diagram, which works like an organisation chart for the problem, with each box becoming a future sub program. Algorithmic thinking means writing out the actual steps.

Linear searchA linear search checks items one by one. It works on a list in any order, but on a large list it can take many checks.
Binary searchA binary search only works on a sorted list. It checks the middle item, discards the half that cannot contain the target, and repeats. For example, to find 16 in [2, 4, 7, 9, 13, 16, 20], the middle value is 9, which is too small, so the lower half is discarded; the middle of the remaining [13, 16, 20] is 16, which is the target, found in 2 checks compared with 6 checks for a linear search.
Bubble sortA bubble sort repeatedly sweeps through the list swapping adjacent pairs that are in the wrong order, so the biggest value bubbles to the end each pass, and it stops once a full pass makes no swaps. It is the simplest sort but also the slowest.
Insertion sortAn insertion sort grows a sorted section of the list one item at a time, sliding each new item into its correct place. It works particularly well on data that is already small or nearly sorted.
Merge sortA merge sort splits the list down to single items and then merges them back together in sorted order. It stays consistently fast on large data, at the cost of using more memory.
🎯 Examiner tip: When picking a sort for an exam scenario: choose bubble sort for a teaching demonstration, insertion sort for small or nearly-sorted data, and merge sort for large data. In 'perform one pass' questions, show the list after every single swap, since a skipped step is a skipped mark.

Flowcharts & trace tables

start / stopprocessdecision?input/outputoval = terminator · rectangle = process · diamond = decision · parallelogram = I/OTrace table: one column per variable, one row per change —step through the code by hand and log every value

Pseudocode can help plan an algorithm. In J277/02 Section B, write code answers in OCR Exam Reference Language or a suitable high-level programming language, following the question. Label examples by language and keep each example consistent. A trace table records variable values while you follow instructions in order. Compare the trace with the expected behaviour to locate a logical error.

Turn these notes into memory. 19 flashcards cover this topic. Short daily sessions, spaced repetition up to your exam date, quizzes with friends. Free during the beta.Practise Algorithms in the app ↗