OCR · GCSE · Computer Science

    Course version: J277 · Version from Sept 2022

    Standard sorting algorithms Bubble sort Merge sort Insertion sort

    Full specification wording

    Searching and sorting algorithms: Standard sorting algorithms Bubble sort Merge sort Insertion sort

    Sorting algorithms arrange data into order, usually ascending.

    Checked against the OCR J277 specification on .

    • Point 2 of 2
    • 4 key terms

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    Sorting algorithms arrange data into order, usually ascending. Bubble sort repeatedly compares adjacent items and swaps them when out of order, so large values 'bubble' to the end; each pass places one more item correctly, and passes repeat until no swaps occur. Insertion sort builds a sorted section at the start: it takes the next item and inserts it into the correct position among those already sorted, shifting larger items right. Merge sort splits the list into single items, then repeatedly merges pairs of sorted sublists by comparing their front items, producing larger sorted lists until one remains. Bubble and insertion sort are simple and suit small lists; merge sort is more efficient on large lists.

    What earns the marks

    • Describes bubble sort comparing adjacent pairs and swapping them when they are in the wrong order, repeating passes until no swaps are needed.
    • Describes insertion sort taking each item in turn and inserting it into its correct position within the already sorted section.
    • Describes merge sort repeatedly splitting the list into smaller sublists until single items remain, then merging sublists in order.
    • Applies a named sorting algorithm to a given list, showing the list after each pass or merge.
    • Compares the algorithms, for example noting that merge sort is generally more efficient on large data sets while bubble and insertion sort are simpler to implement.

    Common mistakes and how to put them right

    • Stopping bubble sort after one pass.

      Put it right: Passes continue until a complete pass produces no swaps, because one pass may not fully sort the list.

    • Merging sublists by simply joining them.

      Put it right: Merging compares the front items of each sorted sublist and takes the smaller one first.

    • Inserting an item without shifting the larger sorted items to the right, which overwrites values and loses data.

    Exam tips

    • Show every pass or merge stage in a trace table or list so the method is visible, not just the final sorted list.
    • Use the correct terminology: 'pass', 'swap', 'insert' and 'merge' signal understanding to the examiner.
    • When comparing algorithms, refer to the number of comparisons or passes needed as list size grows rather than vague statements about speed.

    Try the lesson

    The start of the Searching and sorting algorithms: Standard sorting algorithms Bubble sort Merge sort Insertion sort lesson, made from checked teaching notes for this specification point.

    Have a go first

    Which of these is a standard sorting algorithm that repeatedly compares adjacent items and swaps them if they are in the wrong order?

    Listen

    Sorting algorithms arrange data into order, usually ascending. Bubble sort repeatedly compares adjacent items and swaps them when out of order, so large values 'bubble' to the end; each pass places one more item correctly, and passes repeat until no swaps occur. Insertion sort builds a sorted section at the start: it takes the next item and inserts it into the correct position among those already sorted, shifting larger items right. Merge sort splits the list into single items, then repeatedly merges pairs of sorted sublists by comparing their front items, producing larger sorted lists until one remains. Bubble and insertion sort are simple and suit small lists; merge sort is more efficient on large lists. A strong answer earns marks for these points. Describes bubble sort comparing adjacent pairs and swapping them when they are in the wrong order, repeating passes until no swaps are needed. Describes insertion sort taking each item in turn and inserting it into its correct position within the already sorted section. Describes merge sort repeatedly splitting the list into smaller sublists until single items remain, then merging sublists in order. Applies a named sorting algorithm to a given list, showing the list after each pass or merge. Exam tip: Show every pass or merge stage in a trace table or list so the method is visible, not just the final sorted list.

    See it

    A flowchart with three branches. The first branch starts at Bubble sort, then goes to Compare adjacent items, then Swap when out of order, then Repeat passes until no swaps occur. The second branch starts at Insertion sort, then goes to Build a sorted section at the start, then Take the next item, then Insert into correct position, shifting larger items right. The third branch starts at Merge sort, then goes to Split the list into single items, then Merge pairs of sorted sublists, then Compare front items and take the smaller first, then Repeat until one sorted list remains.
    Shows the steps of bubble sort, insertion sort and merge sort as described in the teaching note.

    Key words

    Say what each word means before you turn the card.

    Bubble sort

    Try answering aloud or in your head before turning the card.

    Insertion sort

    Try answering aloud or in your head before turning the card.

    Merge sort

    Try answering aloud or in your head before turning the card.

    Efficiency of algorithms

    Try answering aloud or in your head before turning the card.

    See every definition
    Bubble sort
    Repeatedly compares adjacent items and swaps them when out of order, so large values bubble to the end, with passes repeated until no swaps occur.
    Insertion sort
    Builds a sorted section at the start by taking the next item and inserting it into the correct position among those already sorted, shifting larger items right.
    Merge sort
    Splits the list into single items, then repeatedly merges pairs of sorted sublists by comparing their front items until one sorted list remains.
    Efficiency of algorithms
    Merge sort is more efficient on large lists, while bubble and insertion sort are simple and suit small lists.

    Label the diagram

    Some boxes have lost their names. Pick the right name for each number.

    The diagram again, with 3 boxes numbered instead of named. A flowchart with three branches. The first branch starts at Bubble sort, then goes to Compare adjacent items, then Swap when out of order, then Repeat passes until no swaps occur. The second branch starts at Insertion sort, then goes to Build a sorted section at the start, then Take the next item, then Insert into correct position, shifting larger items right. The third branch starts at Merge sort, then goes to Split the list into single items, then Merge pairs of sorted sublists, then Compare front items and take the smaller first, then Repeat until one sorted list remains.
    • 1Box 1

    • 2Box 2

    • 3Box 3

    0 of 3 labelled

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

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

    Test your understanding of Searching and sorting algorithms: Standard sorting algorithms Bubble sort Merge sort Insertion sort

    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