TopMyGrade

Notes

Fundamentals of algorithms

An algorithm is a precise, step-by-step set of instructions that solves a problem in a finite number of steps. Algorithms are the heart of computer science — every program is ultimately the execution of one or more algorithms.

Why algorithms matter

Before writing a single line of code, a programmer designs an algorithm. A well-designed algorithm:

  • Solves the problem correctly for all valid inputs
  • Terminates (does not run forever)
  • Is efficient — uses as few steps and as little memory as possible

Key topics in this section

Representing algorithms (CS1.1)

Algorithms can be expressed in three ways:

  • Pseudocode — structured English using programming constructs (IF, WHILE, FOR)
  • Flowcharts — diagrams with standard symbols (start/stop, process, decision, I/O)
  • Written descriptions — plain English numbered steps

No single representation is always best; the choice depends on audience and context.

Efficiency (CS1.2)

We compare algorithms by counting the number of steps they take. For a list of n items:

  • A simple scan through the list takes proportional to n steps — manageable for small lists
  • An algorithm that compares every pair takes proportional to steps — quickly becomes unacceptably slow

Recognising why one algorithm is more efficient than another is a core GCSE skill.

Searching algorithms (CS1.3)

Two algorithms for finding an item in a list:

AlgorithmPreconditionTypical steps
Linear searchNoneUp to n steps
Binary searchList must be sortedUp to log₂(n) steps

Binary search repeatedly halves the search space; linear search checks each item in turn.

Sorting algorithms (CS1.4)

Two algorithms for ordering a list:

AlgorithmMethodEfficiency
Bubble sortRepeatedly swap adjacent itemsO(n²) — slow for large lists
Merge sortDivide list in half, sort each half, mergeO(n log n) — much faster

Bubble sort is simple to trace; merge sort is more efficient but harder to implement.

Common exam skills

  • Trace through an algorithm step by step, showing variable states
  • Identify the number of comparisons or swaps in a given pass
  • Explain why one algorithm is more or less efficient than another
  • Write short algorithms in AQA pseudocode or as a flowchart

Algorithm design principles

A correct algorithm must:

  1. Have clearly defined inputs and outputs
  2. Be unambiguous — every step has one clear meaning
  3. Terminate — must end after a finite number of steps
  4. Be correct — produces the right output for every valid input

These principles apply whether the algorithm is written in pseudocode, a flowchart or a programming language.

AI-generated · claude-opus-4-7 · v3-deep-computer-science

Practice questions

Try each before peeking at the worked solution.

  1. Question 13 marks

    What is an algorithm?

    Define the term "algorithm" and state two properties a correct algorithm must have.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  2. Question 23 marks

    Flowchart symbols

    Name the flowchart symbol used for each of the following: (a) a decision, (b) an input or output, (c) a process.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  3. Question 31 mark

    Comparing representations

    Give one advantage of using a flowchart compared with pseudocode to represent an algorithm.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  4. Question 43 marks

    Algorithm efficiency

    A list of 1024 items needs to be searched. Compare the maximum number of steps taken by a linear search and a binary search.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  5. Question 52 marks

    Choosing a search algorithm

    Explain why binary search cannot always be used instead of linear search.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

Flashcards

CS1 — Fundamentals of algorithms

10-card SR deck for AQA GCSE Computer Science topic CS1

10 cards · spaced repetition (SM-2)