Skip to topic
    ← Back to course topics

    Fundamentals of algorithms — AQA A-Level Computer Science

    Test yourself on Fundamentals of algorithms with AQA A-Level practice questions.

    Start free

    7 days Premium · Then free forever · No card, no charge

    Fundamentals of algorithms explained

    This topic covers the fundamental algorithms used in computer science, focusing on graph and tree traversal, searching, sorting, and optimization.

    Read the full explanation

    It also explores the theoretical aspects of algorithmic complexity, including Big-O notation and the classification of problems as tractable or intractable.

    What to demonstrate

    1. Ability to trace breadth-first and depth-first search algorithms
    2. Ability to trace pre-order, post-order, and in-order tree-traversal algorithms
    3. Ability to convert between infix and Reverse Polish notation
    Show all 8 objectives
    1. Knowledge of time complexity for linear search, binary search, and binary tree search
    2. Knowledge of time complexity for bubble sort and merge sort
    3. Ability to trace Dijkstra’s shortest path algorithm
    4. Understanding of Big-O notation for constant, logarithmic, linear, polynomial, and exponential time
    5. Understanding of the Halting problem and its significance

    Fundamentals of algorithms exam tips

    Topic Overview

    Fundamentals of algorithms is the bedrock of computer science, covering the design, analysis, and implementation of step-by-step procedures to solve problems. This topic introduces you to key concepts such as algorithmic thinking, decomposition, abstraction, and the use of standard algorithms like searching and sorting. Mastering these fundamentals is essential because algorithms are at the heart of every software system, from simple calculators to complex AI. In the AQA A-Level, you'll learn to write algorithms in pseudocode and flowcharts, analyse their efficiency, and apply them to real-world scenarios.

    Understanding algorithms is not just about memorising steps; it's about developing a logical mindset that allows you to break down problems into manageable parts. This topic connects directly to data structures, programming, and computational thinking. For example, knowing how a binary search works helps you understand why certain data structures (like sorted arrays) are efficient. In exams, you'll be expected to trace algorithms, identify errors, and compare their performance using Big O notation. This foundational knowledge is crucial for higher-level topics like graph algorithms and recursion.

    Algorithms are everywhere: from Google's search engine to Netflix's recommendation system. By studying this topic, you'll gain the skills to create efficient solutions and appreciate the trade-offs between time and space complexity. The AQA specification emphasises practical application, so you'll often be asked to implement algorithms in a programming language or pseudocode. This topic also lays the groundwork for the non-exam assessment (NEA), where you'll design and evaluate your own algorithms to solve a problem of your choice.

    Key Concepts
    • →Algorithmic thinking: The ability to break down problems into clear, logical steps and represent them as algorithms using pseudocode or flowcharts.
    • →Searching algorithms: Linear search (O(n)) and binary search (O(log n)) – understand their steps, efficiency, and when to use each (binary search requires sorted data).
    • →Sorting algorithms: Bubble sort (O(n^2)), merge sort (O(n log n)), and insertion sort (O(n^2)) – know how they work, their best/worst-case complexities, and stability.
    • →Big O notation: A way to describe the time and space complexity of an algorithm, focusing on the worst-case scenario. For example, O(1) is constant time, O(n) is linear, O(n^2) is quadratic.
    • →Trace tables: A method to manually execute an algorithm step by step, recording variable values to verify correctness or find errors.
    Marking Points
    • Ability to trace breadth-first and depth-first search algorithms
    • Ability to trace pre-order, post-order, and in-order tree-traversal algorithms
    • Ability to convert between infix and Reverse Polish notation
    • Knowledge of time complexity for linear search, binary search, and binary tree search
    • Knowledge of time complexity for bubble sort and merge sort
    • Ability to trace Dijkstra’s shortest path algorithm
    • Understanding of Big-O notation for constant, logarithmic, linear, polynomial, and exponential time
    • Understanding of the Halting problem and its significance
    Examiner Tips
    • 💡Practice tracing algorithms manually on paper to ensure accuracy
    • 💡Memorize the time complexity classes (O(1), O(log n), O(n), O(n log n), O(n^2), O(2^n))
    • 💡Use clear, step-by-step notation when converting to RPN
    • 💡Ensure you can explain the 'Divide and Conquer' approach used in merge sort
    • 💡Be prepared to explain the significance of the Halting problem as a limit of computation
    • 💡When tracing algorithms, always use a trace table and update variables systematically. Examiners look for clear, step-by-step working – even if your final answer is wrong, you can get marks for correct intermediate steps.
    • 💡For algorithm design questions, start by writing the steps in plain English (pseudocode) before translating into a specific programming language. This shows your understanding of the logic and helps avoid syntax errors.
    • 💡When comparing algorithms, always refer to Big O notation and justify your answer with specific examples (e.g., 'Binary search is faster than linear search for large sorted datasets because it halves the search space each iteration, giving O(log n) vs O(n)').
    Common Mistakes
    • Confusing the order of traversal in tree algorithms (e.g., pre-order vs post-order)
    • Incorrectly calculating time complexity for algorithms
    • Failing to correctly convert infix expressions to RPN
    • Misunderstanding the difference between tractable and intractable problems
    • Inability to correctly trace Dijkstra's algorithm steps
    • Misconception: Binary search can be used on any list. Correction: Binary search only works on sorted data. If the list is unsorted, you must sort it first or use linear search.
    • Misconception: Merge sort always takes the same amount of time. Correction: Merge sort has a consistent O(n log n) time complexity regardless of input order, but it requires additional memory for merging, so it's not always the best choice for small datasets.
    • Misconception: Bubble sort is the slowest sorting algorithm. Correction: While bubble sort is generally inefficient (O(n^2)), it can be optimised to stop early if no swaps occur, making it O(n) on an already sorted list. However, insertion sort often performs better in practice.
    Frequently Asked Questions
    What is the difference between linear search and binary search?
    Linear search checks each element in a list one by one until it finds the target or reaches the end. It works on any list but has O(n) time complexity. Binary search repeatedly divides a sorted list in half, comparing the target to the middle element. It only works on sorted lists but is much faster with O(log n) complexity. For example, searching a list of 1000 items: linear search may take up to 1000 steps, while binary search takes at most 10 steps.
    How do I choose which sorting algorithm to use?
    It depends on the data size and structure. For small lists (under 50 items), insertion sort is often fastest due to low overhead. For larger lists, merge sort is reliable with O(n log n) time, but it uses extra memory. Bubble sort is rarely used in practice except for educational purposes. If the list is nearly sorted, insertion sort or optimised bubble sort can be efficient. Always consider the trade-off between time, memory, and stability.
    What is Big O notation and why is it important?
    Big O notation describes the worst-case time or space complexity of an algorithm as the input size grows. It ignores constants and lower-order terms to focus on the dominant factor. For example, O(n) means the time grows linearly with input size, while O(n^2) grows quadratically. It's important because it helps you compare algorithms and predict performance for large datasets. In exams, you'll be asked to state the complexity of algorithms and explain why one is better than another.
    How do I trace an algorithm in an exam?
    Draw a trace table with columns for each variable and a row for each step. Start with initial values, then execute the algorithm line by line, updating variables as you go. For loops, note the iteration number and the condition check. This methodical approach ensures you don't miss steps and makes it easy for examiners to award partial marks. Practice with past papers to get comfortable with different algorithm types.
    What is the difference between an algorithm and a program?
    An algorithm is a step-by-step set of instructions to solve a problem, written in pseudocode or a flowchart. It is language-independent and focuses on logic. A program is the implementation of an algorithm in a specific programming language (like Python or Java). The same algorithm can be coded in many languages. In exams, you may be asked to write an algorithm in pseudocode and then implement it in a programming language.
    Why do we need to learn sorting algorithms if Python has built-in sort?
    Built-in functions are convenient, but understanding sorting algorithms teaches you fundamental concepts like recursion, divide-and-conquer, and complexity analysis. These skills transfer to designing your own algorithms for problems where no built-in solution exists. Additionally, exam questions often ask you to implement or trace sorting algorithms manually, so you need to know how they work internally.