Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Lesson details

      Learning outcome

      I can perform a bubble sort to order data in a list.

      Key learning points

      1. The bubble sort algorithm works by repeatedly going through a list.
      2. It compares adjacent items and swaps the items if they are in the wrong order.
      3. Each time the algorithm goes through the list it is called a pass.
      4. The pass through the list is repeated until no more changes are made on a pass.

      Keywords

      • Bubble sort - a sorting algorithm that repeatedly compares pairs of values within a list and swaps them if they are out of order

      • Pass - a complete traversal of a list

      Common misconception

      The bubble sort algorithm stops on the last swap.

      The pass through the list is repeated until no more changes are made on a pass. The last pass is needed to confirm the data is in order.

      Teacher tip

      Bubble sort is so named as it is analogous to a bubble passing over and comparing pairs of data. Finding ways to compare the operation of abstract concepts found in computing can help pupils contextualise what they are learning about when the concept is difficult to grasp.

      Licence

      This content is © Oak National Academy Limited (2025), licensed on Open Government Licence version 3.0
      except where otherwise stated. See Oak's terms & conditions
      (Collection 2).

      Lesson video

      Loading...

      Prior knowledge starter quiz

      6 Questions

      Q1.
      What is an algorithm?

      a programming language
      a type of data structure
      a trace table
      Correct answer: a set of step-by-step instructions to solve a problem

      Q2.
      Which searching algorithm is simpler to code?

      binary search
      Correct answer: linear search
      interpolation search
      bubble search

      Q3.
      What is the purpose of a trace table?

      to debug code
      Correct answer: to track the values of variables and the flow of execution
      to store data
      to write algorithms

      Q4.
      Which of the following is a characteristic of a binary search?

      It checks every element in the list.
      It works only with unsorted data.
      It’s simpler than a linear search.
      Correct answer: It splits the data into halves to search efficiently.

      Q5.
      What does a linear search do?

      splits data into halves
      uses a trace table to debug code
      Correct answer: searches sequentially through each element
      sorts the data first

      Q6.
      What is required for binary search?

      Correct answer: The data must be sorted.
      The data must be unsorted.
      The data must be small.
      The data must be large.

      6 Questions

      Q1.
      Which sorting algorithm repeatedly compares and swaps adjacent items in a list?

      Correct Answer: bubble sort, bubble

      Q2.
      What does the bubble sort algorithm do?

      Correct answer: compares adjacent items and swaps them if needed
      divides the list into halves and sorts each half
      searches for a specific value in the list
      tracks the number of passes in a trace table

      Q3.
      What is the purpose of swapping items in the bubble sort algorithm?

      to remove duplicates
      to divide the list into smaller parts
      to create a trace table
      Correct answer: to order the list correctly

      Q4.
      How many passes are required to complete a bubble sort?

      one pass
      a fixed number of passes
      Correct answer: until no more swaps are needed
      until the largest value is found

      Q5.
      Arrange the steps to perform one pass of a bubble sort:

      1 - compare adjacent items
      2 - swap items if they are in the wrong order
      3 - move to the next pair of items
      4 - repeat until the end of the list is reached

      Q6.
      Match the actions to their purposes:

      Correct Answer:performing a pass,compares all adjacent items in the list

      compares all adjacent items in the list

      Correct Answer:swapping items,ensures the list is ordered

      ensures the list is ordered

      Correct Answer:repeating passes,fully sorts the list

      fully sorts the list

      Correct Answer:stopping the algorithm,indicates no swaps were needed

      indicates no swaps were needed


      To help you plan your 10 computer science lesson on: Bubble sort, download all teaching resources for free and adapt to suit your pupils' needs...