Merge Sort vs. Insertion Sort

Pre-requisite: Merge Sort, Insertion Sort

Merge Sort: is an external algorithm and based on divide and conquer strategy. In this sorting:

  1. The elements are split into two sub-arrays (n/2) again and again until only one element is left.
  2. Merge sort uses additional storage for sorting the auxiliary array.
  3. Merge sort uses three arrays where two are used for storing each half, and the third external one is used to store the final sorted list by merging the other two and each array is then sorted recursively.
  4. At last, all sub-arrays are merged to make it ‘n’ element size of the array.

Below is the image to illustrate Merge Sort:

Insertion Sort is a sorting algorithm in which elements are taken from an unsorted item, inserting it in sorted order in front of the other items, and repeating until all items are in order. The algorithm is simple to implement and usually consists of two loops: an outer loop to pick items and an inner loop to iterate through the array. It works on the principle of the sorting playing cards in our hands.

Below is the image to illustrate Insertion Sort:

Difference between Merge sort and Insertion sort:

Tabular Representation:

Parameters Merge Sort Insertion Sort
Worst Case Complexity O(N*log N) O(N2)
Average Case Complexity O(N*log N) O(N2)
Best Case Complexity O(N*log N) O(N)
Auxiliary Space Complexity O(N) O(1)
Works well on On huge dataset. On small dataset.
Efficiency Comparitively Efficient. Comparitively Inefficient.
Inplace Sorting No Yes
Algorithm Paradigm Divide and Conquer Incremental Approach
Uses It is used for sorting linked list in O(N*log N), for Inversion Count problem, External sorting, etc. It is used when number of elements is small. It can also be useful when input array is almost sorted, only few elements are misplaced in complete big array.

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :