It is a divide & conquer algorithm that breaks down the given array into smaller sub-arrays until the sub-arrays become so small that they can't be divided further. The algorithm then merges these sub-arrays, in order, to produce a sorted array.

Runtime Complexity of O(n log n) (Regardless of the input array's order, Merge Sort has the same time complexity due to its recursive nature and the way it splits and merges the subarrays.)
Space Complexity of O(n). (The space complexity is linear because the total number of elements in the subarrays is equal to the number of elements in the input array.)
This makes it faster than other sorting algorithms, such as insertion sort, selection sort, and bubble sort when working with large data sets.
Implementing the Merge Sort algorithm in code involves creating a recursive function that divides the original array into sub-arrays and sorts them. We also need to create a helper function that merges the sorted sub-arrays back into the original array.
mergeSort that takes an array as an argument and recursively divides the array into left and right sub-arrays.merge that takes the left and right sub-arrays and merges them back into the original array.mergeSort function to sort the elements.mergeSort function, use recursion to divide the array into smaller sub-arrays until each sub-array has only one element.