Math Fundamentals18 sections · 814 units
Open in Course

Linearithmic Example

(Merge sort)

Merge sort splits the array in half, recursively sorts each half, then merges. The splitting takes log n levels. Each level processes all n elements.

Total work: n elements × log n levels = n log n operations.

This is O(n log n). Sorting 1000 elements takes roughly 10,000 steps instead of 1,000,000 for quadratic sorts.