Chhetri AcademyGCSE & A level Paper Builder

1.2.6bBubble sort and merge sort

Edexcel GCSE Computer Science (1CP2) · Computational thinking › Algorithms

Practise Bubble sort and merge sort. 13 exam-style questions plus unlimited generated ones on this subtopic, at up to four difficulty levels, with full mark schemes and a progress tracker. Free, no account needed.

Build a paper on this topic

▶ Watch videos on Bubble sort and merge sort (Craig 'n' Dave Edexcel on YouTube) · Practise all of Algorithms

Quick recall

Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.

Bubble sort is a sorting algorithm. Define the term 'pass' in a bubble sort.
One run through the list, comparing each adjacent pair once.
Give one advantage of a merge sort compared with a bubble sort.
It is much faster for large lists.

Sample questions

Written for this site in the style of Edexcel exam questions. They are not taken from real past papers.

Question 1Easy4 marks
Bubble sort is a sorting algorithm.
(a) Describe how a bubble sort puts a list of numbers into ascending order.[3]
(b) Define the term 'pass' in a bubble sort.[1]
Show the answer and mark scheme
(a) Answer: It compares each pair of adjacent items, swapping them if they are in the wrong order, and repeats passes through the list until a pass makes no swaps.
  • compares adjacent pairs of items (from the start of the list)
  • swaps them if they are in the wrong order
  • repeats passes through the list until no swaps are made / the list is sorted
(b) Answer: One run through the list, comparing each adjacent pair once.
  • one run through the list comparing each adjacent pair (once)
Question 2Medium6 marks
A bubble sort is used to put a list of numbers into ascending order.
(a) Explain why the largest number is always in the last position after the first pass.[2]
(b) Explain how a bubble sort can tell that the list is sorted before it has made the maximum number of passes.[2]
(c) Write the list [27, 9, 41, 13, 30, 6] as it would be after the first pass.[2]
Show the answer and mark scheme
(a) Answer: Whenever the largest number is compared with the item after it, it is swapped, so it moves along one place at every comparison until it reaches the end.
  • the largest number is always swapped when it is compared with the next item
  • so it moves (bubbles) along the list until it reaches the end
(b) Answer: If a whole pass is made without any swaps, every adjacent pair is in order, so the list is sorted and the algorithm can stop.
  • if a complete pass makes no swaps
  • every pair is in order, so the list is sorted and the algorithm can stop
(c) Answer: [9, 27, 13, 30, 6, 41]
  • 41 is in the last position
  • the other items are in the order 9, 27, 13, 30, 6
Question 3Hard7 marks
(a) Merge sort is a divide and conquer algorithm.
Describe how merge sort sorts a list. Refer to the divide and conquer stages in your answer.[4]
(b) Explain why merge sort is usually much faster than bubble sort for a large list.[2]
(c) Give one disadvantage of merge sort compared with bubble sort.[1]
Show the answer and mark scheme
(a) Answer: Split the list in half repeatedly until every sub-list has one item, then merge pairs of sub-lists in order until one sorted list is left.
  • divide: the list is split into two halves
  • the halves are split again and again until each sub-list contains only one item (a list of one item is already sorted)
  • conquer: pairs of sub-lists are merged to make larger sorted sub-lists
  • when two sub-lists are merged, their first items are compared and the smaller one is moved into the new list, until both sub-lists are empty
  • merging continues until there is one sorted list
(b) Answer: Bubble sort may need many passes comparing neighbours; merge sort's halving and merging needs far fewer comparisons.
  • bubble sort compares neighbouring items and may need to pass through the whole list many times
  • merge sort splits the list into halves and merges the sorted halves, so it makes far fewer comparisons for a large list
(c) Answer: It needs more memory for the sub-lists.
  • it uses more memory, because it creates extra sub-lists while it works / it is more complicated to program

Related subtopics

Stuck? Get 1-to-1 help. Chhetri Academy tutors GCSE and A level Maths and Science online, with a free 30-minute trial lesson.

Book a free trial