Mergesort is an extremely efficient sorting algorithm, compared to selection and insertion. Mergesort utilizes recursion to achieve efficient sorting of lists.
How it works
Mergesort uses what is known as a "Divide and Conquer" strategy. This means mergesort divides the problem into smaller parts until the array length is equal to one. Then it merges together adjacent arrays and sorts them until the whole list is sorted.
It is important to know that if you utilize mergesort you will need to have extra space for temporary storage.
Mergesort is also recursive, meaning it calls upon itself.
In a more advanced setting we can observe that the runtime complexity of mergesort is O(nlogn). This means that mergesort is a linear (n), and the operation occurs in log(n) steps.