Merge sort and bubble sortA sorting algorithm that repeatedly passes through a list to be sorted, comparing and swapping items that are in the wrong order. are two types of algorithmA sequence of logical instructions for carrying out a task. In computing, algorithms are needed to design computer programs. 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.