Pearson Edexcel · GCSE · Computer Science

    Course version: Pearson-GCSE-Computer-Science · Version from Mar 2026

    Algorithms

    Master the logic behind every computer program. This topic covers how to design, trace, and evaluate algorithms using sequence, selection, and iteration, plus the essential searching and sorting techniques you'll need for your exam.

    • 6 min read
    • 3 worked examples
    • 5 practice questions
    • 6 key terms

    Study Notes

    Overview

    Algorithms are the foundation of Computer Science. They are simply finite sequences of clear, unambiguous instructions used to solve problems or achieve objectives. Whether you are programming a simple calculator or the AI behind a self-driving car, you are using algorithms.

    In your GCSE exam, you won't just be asked to write code; you will be tested on your computational thinking. This means you must be able to design algorithms using flowcharts and pseudocode, trace existing algorithms to see what they do, and evaluate different algorithms to determine which is more efficient. This topic connects heavily to programming constructs and data structures. Examiners love testing this through trace tables, identifying errors in code, and comparing searching/sorting methods.


    Key Concepts

    Concept 1: The Three Constructs

    Every single algorithm, no matter how complex, is built from just three fundamental building blocks:

    1. Sequence: Instructions are executed one after another, in the exact order they are written.
    2. Selection: The algorithm makes a decision and chooses a path based on a condition. We use IF...THEN...ELSE statements for this. In a flowchart, this is represented by a diamond.
    3. Iteration: The algorithm repeats a block of code. This is also known as looping.

    **Understanding Iteration:**There are two types of iteration you must distinguish between:

    • Count-controlled iteration: Repeats a specific, known number of times. We use a FOR loop for this. (e.g., "Do this 10 times").
    • Condition-controlled iteration: Repeats until a specific condition is met. We use a WHILE or REPEAT UNTIL loop for this. (e.g., "Keep asking for a password UNTIL the correct one is entered").

    Examiner Tip: Confusing these two is a very common mistake. Remember: FOR loops count, WHILE loops check conditions.

    Concept 2: Trace Tables

    A trace table is a manual way of stepping through an algorithm to track the changing values of variables. It is the most reliable way to figure out what a piece of code does or to find a logic error.

    How to use them:

    1. Create a column for every variable in the algorithm.
    2. Create a separate column for any OUTPUT.
    3. Work through the algorithm line by line. Every time a variable changes, write the new value in the correct column on a new row.

    Why this works: Computers don't skip steps or make assumptions. By forcing yourself to write down the value at every single step, you act like the CPU, preventing you from making human logic leaps that lead to wrong answers.

    Concept 3: Types of Errors

    When writing algorithms, things go wrong. You must be able to identify three types of errors:

    • Syntax Error: A mistake in the grammar or rules of the programming language. (e.g., missing a bracket, misspelling WHILE as WHLIE). The code will not run.
    • Logic Error: The code runs perfectly without crashing, but it produces the wrong result. (e.g., using > instead of >=). The programmer's reasoning was flawed.
    • Runtime Error: The code is grammatically correct, but something goes wrong while the program is executing, causing it to crash. (e.g., trying to divide a number by zero, or trying to open a file that doesn't exist).

    Concept 4: Searching Algorithms

    Searching Algorithms: Linear vs Binary SearchOpen full-size image (opens in a new tab)

    Computers need to find data quickly. You must know two methods:

    Linear Search:

    • How it works: Starts at the first item and checks every single item one by one until the target is found or the end of the list is reached.
    • Advantage: Works on unsorted lists.
    • Disadvantage: Very slow for large lists (inefficient).

    Binary Search:

    • How it works: Looks at the middle item. If the target is smaller, it discards the right half. If the target is larger, it discards the left half. It repeats this halving process until the item is found.
    • Advantage: Extremely fast and efficient for large lists.
    • Disadvantage: The list MUST be sorted first. (Examiners will almost always test this fact!).

    Concept 5: Sorting Algorithms

    Sorting Algorithms: Bubble Sort vs Merge SortOpen full-size image (opens in a new tab)

    Organising data is crucial. You must know two sorting methods:

    Bubble Sort:

    • How it works: Compares adjacent pairs of items. If they are in the wrong order, it swaps them. It makes multiple passes through the list. After each pass, the largest unsorted item "bubbles" up to its correct position at the end.
    • Pros/Cons: Simple to write and uses very little memory (sorts in place). However, it is very slow for large lists.

    Merge Sort:

    • How it works: Uses a "divide and conquer" approach. It repeatedly splits the list in half until every item is in its own list of one. Then, it merges pairs of lists back together in the correct order until one sorted list remains.
    • Pros/Cons: Much faster than bubble sort for large lists. However, it requires more memory because it creates new lists during the splitting and merging process.

    Listen to the Podcast

    Reinforce your learning by listening to our 8-minute deep dive into Algorithms, featuring examiner tips and a quick-fire recall quiz.


    Mathematical/Scientific Relationships

    While not formulas in the traditional physics sense, you must understand the relational and logical operators used in algorithms:

    • == or = : Equal to
    • != or <> : Not equal to
    • < : Less than
    • <= : Less than or equal to
    • > : Greater than
    • >= : Greater than or equal to
    • AND : Both conditions must be true
    • OR : At least one condition must be true
    • NOT : Reverses the logical state (True becomes False)

    Practical Applications

    • Binary Search in the real world: When you search for a contact in your phone, the software uses a binary search (or similar efficient algorithm) to find the name instantly out of thousands, because your contacts are kept alphabetically sorted.
    • Trace Tables: Software developers use "debuggers" which essentially automate the trace table process, allowing them to step through code line-by-line to watch variables change and catch logic errors.

    Check what you remember

    Read the wording for your board, then hide it and explain Algorithm in your own words. Rough notes are fine. This is a self-check, with no mark or grade.

    Reference: Pearson Edexcel

    A finite sequence of clear, unambiguous instructions used to solve a problem.
    Pearson Edexcel

    Interactive Diagrams

    2 interactive diagrams to visualise key concepts

    Conceptual Flow Outline

    Start
    ➔INPUT age
    INPUT age
    ➔age >= 18?
    age >= 18?
    ➔YesOUTPUT 'Adult'
    ➔NoOUTPUT 'Child'
    OUTPUT 'Adult'
    ➔End
    OUTPUT 'Child'
    ➔End

    Flowchart demonstrating Selection (IF statement)

    Conceptual Flow Outline

    Start
    ➔SET count = 1
    SET count = 1
    ➔count <= 5?
    count <= 5?
    ➔YesOUTPUT count
    ➔NoEnd
    OUTPUT count
    ➔SET count = count + 1
    SET count = count + 1
    ➔count <= 5?

    Flowchart demonstrating Iteration (WHILE loop)

    Worked Examples

    3 worked examples — open one to explore the question and available guidance.

    Practice Questions

    Try the question, then reveal an answer plan or example response

    Q1

    State the three basic programming constructs used to design algorithms. (3 marks)

    3 marks
    foundation

    Hint: Think about the order of code, making decisions, and repeating code.

    Q2

    A program asks a user to input a password. It checks if the password is 'letmein123'. If it is, it outputs 'Access Granted'. If not, it outputs 'Access Denied'. Write pseudocode for this algorithm. (4 marks)

    4 marks
    standard

    Hint: You need an INPUT, an IF statement, an ELSE, and two OUTPUTs.

    Q3

    Explain one advantage of using a binary search rather than a linear search. (2 marks)

    2 marks
    standard

    Hint: Think about speed and how many items need to be checked.

    Q4

    Explain the difference between a syntax error and a logic error. (2 marks)

    2 marks
    standard

    Hint: Which one stops the program from running?

    Q5

    An algorithm uses a bubble sort to sort the array [7, 2, 9, 1]. Show the state of the array after the first complete pass. (2 marks)

    2 marks
    challenging

    Hint: Remember to compare adjacent pairs. 7 and 2, then 7 and 9, then 9 and 1.

    Ready to test yourself interactively?

    Active recall beats reading alone. Answer questions on Algorithms with instant AI scoring and mark scheme guidance.

    Start interactive practice

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Exam technique

    How to turn what you know into marks

    How to approach the question

    Always read the command word first. If given pseudocode, trace it line by line on the exam paper with your pen. Don't try to hold variable values in your head.

    How to structure your answer

    For 'Evaluate' algorithms questions: Paragraph 1 (Algorithm A pros/cons), Paragraph 2 (Algorithm B pros/cons), Paragraph 3 (Conclusion based on the scenario).

    Timing

    Approximately 1 minute per mark, so a 6-mark question should take about 6-7 minutes

    Common pitfalls

    • Confusing logic errors with syntax errors.
    • Failing to update the loop counter in a trace table.
    • Describing a generic binary search instead of applying it to the numbers given in the question.
    • Forgetting that binary search ONLY works on sorted lists.

    What the command words want

    Compare
    Identify similarities AND differences - use comparative language (e.g., 'whereas', 'however').
    Explain
    Say HOW or WHY - use 'because' to link cause and effect.
    Describe
    Say what happens or what something is like - use correct terminology.
    Evaluate
    Consider both sides (pros and cons), use evidence, and make a clear judgement/conclusion.
    Calculate
    Show working, use correct formula, include units.
    State/Give
    Brief factual answer - 1-2 words or a short phrase. No explanation needed.
    Watch or listen (optional)
    Interactive Video Explainer
    AI Generated • 3-4 Mins
    🎙 Podcast Episode
    Algorithms
    0:00-0:00

    Test your understanding of Algorithms

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge