Merge Sort Algorithm in Python

Merge sort algorithm is based on the divide and conquer algorithm. Although this algorithm consumes more memory, this algorithm is widely used nowadays because of its less complexity.

Below are the few important things to consider while using this algorithm,

  1. Merge sort is efficient to use when the data set is very large. If the array size is smaller, you can use quicksort.
  2. Merge sort is a stable algorithm. It means that this sort preserves the sorting of the other dependent columns. Please refer to for more information.
  3. The time complexity is O(n logn) and the space complexity is O(n).
  4. More suitable for the linked list than arrays.

Please find below the python coding for the merge sort algorithm:

Happy Learning!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store