Time Complexity
A measure of how an algorithm's running time scales with the size of its input.
Definition
Time complexity quantifies the number of basic operations an algorithm performs as a function of input size, usually expressed in big-O notation. Space complexity does the same for memory.
Amortized analysis captures the average cost per operation over a sequence, which matters for structures like dynamic arrays whose occasional expensive resize is spread across many cheap operations. It explains why some operations that are sometimes slow are still efficient in aggregate.
Worst-case analysis provides guarantees but can be pessimistic for inputs seen in practice, which is why average-case and amortized analyses complement it. The quicksort algorithm, for instance, has a poor worst case yet excellent average behavior, and dynamic arrays are efficient in aggregate despite occasional costly resizes. Choosing which analysis to trust depends on whether the application needs guarantees or typical-case speed.
Cases
- Best case: fewest operations for favorable input.
- Average case: expected operations over typical input.
- Worst case: the guaranteed upper bound, often the key metric.
Why it matters
Time complexity predicts how an algorithm behaves as data grows, which is what determines feasibility at scale. A method that is fast on small tests may be unusable on real data if it scales poorly, so worst-case analysis guards against unpleasant surprises.
Fusion connection
Kronos weighs the time complexity of candidate solvers to keep large parameter sweeps and high-resolution simulations of Hyperion within available compute budgets.