Merge Sort
Explore how merge sort works by recursively splitting arrays into halves and merging them in order. Learn to implement this stable sorting algorithm in Go, appreciating its O(n log n) performance across all cases and its ideal use with linked lists.
We'll cover the following...
We'll cover the following...
Introduction
Merge sort recursively partitions the input into two halves. The two halves are then sorted independently before being combined into the final sorted output. The recursive step keeps on dividing the input into smaller pieces until the length of each piece becomes one.
Let’s look at an illustration of the merge sort in action.
Code example
Analysis
- The time complexity of merge sort is