Merge Sort & Library Merge
In short: merge sort is divide-and-conquer: split the list in half, sort each half by calling itself (recursion), then merge the two sorted halves with one pass of two pointers. The base case is 0 or 1 items. Every level of the split tree touches all n items once, and halving reaches size 1 after log₂ n levels, so the whole sort is O(n log n) — reliably, no matter how the input starts out — at the cost of O(n) extra space for the merges.

Merge a phone library with a laptop library
A listener signs in on a new laptop. Their phone library is sorted A→Z, and so is the laptop's. Gluing them together and re-sorting from scratch would throw away order you already have — merging walks the two fronts once and is done:
The same merge, now on five play counts with every comparison drawn:
The merge only ever compares the two fronts, so it finishes in one pass over both lists.
The fronts are 2 from a and 1 from b. 10 cells. i at index 0. j at index 2. k at index 5. Comparing 2 and 1.
The mistake: stopping as soon as either list runs out and forgetting the leftover copy. The tail of the longer list silently disappears:
This should print all five titles in order. It prints three — "Dawn" and "Glow" are lost when the second list runs out.
Comparisons stop the moment either list empties — at most n + m − 1 of them:
def merge_comparisons(a, b):
i = j = count = 0
while i < len(a) and j < len(b):
count += 1
if a[i] <= b[j]:
i += 1
else:
j += 1
return count
print(merge_comparisons([1, 2, 3], [4, 5, 6]))