ONLogN Linearithmic Time

1 min read
Foundational1 min read
Rapid overview

ONLogN Linearithmic Time

TL;DR

O(n log n) linearithmic time is the cost of doing log-many passes over n elements — the floor for comparison-based sorting and the hallmark of divide-and-conquer algorithms like merge sort and quicksort. It's only slightly worse than linear, so a senior engineer treats "just sort it first" as a cheap enabler for faster downstream lookups rather than a bottleneck.

How it works

const sorted = [...items].sort((a, b) => a - b);

Notes

  • Most comparison-based sorting is O(n log n).
  • Sorting dominates when combined with O(log n) lookups.

See also