What is Big O notation and what does O(n log n) mean?
spaceto flip
Big O describes how an algorithm's time or space grows with input size. O(1): constant. O(log n): halving each step (binary search). O(n): linear. O(n log n): sorting (merge sort, quicksort average). O(n^2): nested loops. O(n log n) means for each of n elements, you do log n work -- typical of efficient sorting.