Merge sort is an efficient and recursive algorithm for sorting an array. To sort an array recursively, merge-sort splits the array into two and sorts each half. Then, it uses the merge operation to combine the two sorted halfs into a single sorted array.
First, we will see how the merge operation works. Then, we will see how the merge-sort algorithm works as whole.