Searching and sorting algorithms - AQAComparing merge and bubble sorts

Sorting and searching are two of the most frequently needed algorithms in program design. These algorithms have evolved to take account of this need.

Part ofComputer ScienceComputational thinking and problem solving

Comparing merge and bubble sorts

Merge sort and are two types of used for sorting lists. Although merge and bubble sort algorithms produce the same overall results, the merge sort is more efficient for large data sets. However, the bubble sort is a very simple algorithm and it does not use much memory.

Merge sort

Advantages

  • A merge sort uses smaller, ordered lists which are easier to sort and merge than larger lists.
  • It is usually more efficient and quicker than the bubble sort.

Disadvantages

  • It is more complex to code.
  • It will still go through the split and merge process when the list is already in order.
  • It is less memory efficient than the bubble sort as it uses multiple lists.

Bubble sort

The bubble sort is the simplest of the two sorting algorithms as it only focuses on sorting two items at a time.

Advantages

  • It is simpler to code.
  • It’s easier to check if a list is in order, as it only needs one pass of the data to check that it's in order.
  • It is memory efficient as it uses only one list.

Disadvantages

  • It is inefficient on large data sets due to the number of comparisons required.
  • It will take a long time to sort a very large list of items.