Learn VisualLearn CS

How Merge Sort Works

Merge sort merges neighboring sorted sub-lists two at a time. At the start, every single element counts as a sorted sub-list of length 1. Merging means repeatedly comparing the fronts of both sub-lists and taking the smaller one. Repeating this merge until only one sub-list remains leaves the whole array sorted.

GOAL

Explain how merge sort sorts an array by merging pairs of sorted sub-lists.

Merging the sorted sub-lists [2, 5] and [1, 8], which value comes out first?