<DS/>DS_VISUALIZER
FoundationsOOPArraysLinked ListStacksQueuesTreesGraphsHashingStrings
exploreExplore
homechevron_rightTopicschevron_rightFoundationschevron_rightComplexity Analysis
analytics

FOUNDATIONS · ANALYSIS

Complexity Analysis

Time, space, and the three cases — formalise the cost of any algorithm.

Choose a lesson

schedulearrow_outward

Time Complexity

T(n): steps as a FUNCTION of input size.

O(n)O(1)
memoryarrow_outward

Space Complexity

Count extra memory boxes, not seconds.

O(n)O(1) vs O(n)
sentiment_satisfiedarrow_outward

Best Case

The luckiest input — Ω(1) for linear search.

Ω(1)O(1)
sentiment_dissatisfiedarrow_outward

Worst Case

The guarantee — what the O(·) badges mean.

O(n)O(1)
sentiment_neutralarrow_outward

Average Case

Expected cost over typical inputs — Θ(n).

Θ(n)O(1)