Complexity formulas
Asymptotic complexity and recurrences. 14 formulas for GATE CS, DA Data Structures and Algorithms, each with when to use it. Each is explained in the topic notes.
IAE Academy: Asymptotic complexity and recurrences formulas (GATE CS, DA)
All 14 Complexity formulas
BIG-O (UPPER BOUND)
grows no faster than , up to a constant factor.
BIG-OMEGA (LOWER BOUND)
grows at least as fast as , up to a constant factor.
BIG-THETA (TIGHT BOUND)
and grow at the same rate. Equivalently, and both hold.
CHANGE OF BASE FOR LOGARITHMS
The two logarithms differ only by the constant factor , which is why the base is irrelevant inside , and .
LOG VS POLYNOMIAL VS EXPONENTIAL VS FACTORIAL
These three limits give the dominance rules:
- Any positive power of beats any power of .
- Any exponential with base greater than 1 beats any fixed power of .
- beats any exponential with a constant base.
STIRLING'S APPROXIMATION AND LOG(N!)
Consequences:
- and .
- The elementary bounds are enough on their own to give .
- This result is behind the lower bound on the number of comparisons for comparison-based sorting: a decision tree with leaves has height at least .
EXPONENT-LOG SWAP IDENTITY
Take of both sides: each becomes . Examples: , , , .
ARITHMETIC SERIES
This is the count when the inner loop runs exactly times as goes from 1 to . If the inner loop runs times, the exact count changes to , and times gives . Both are still when .
SUMS OF POWERS
This applies to triple loops such as from 1 to , from 1 to , from 1 to , and to inner loops that run times.
GEOMETRIC SERIES
When , the sum is . When , it is .
HARMONIC SERIES AND LOG(N!)
The harmonic sum appears when an inner loop steps by the outer index (inner count about ). The sum appears when an inner loop runs times.
MULTIPLICATIVE (LOGARITHMIC) LOOP
This is the exact count for for (i = 1; i <= n; i *= c). For example, with and the loop runs times, not 10.
MASTER THEOREM: GENERAL FORM
is the number of subproblems, is the factor by which the size shrinks, and is the work done outside the recursive calls (dividing plus combining). Compare with , which is the number of leaves of the recursion tree.
MASTER THEOREM FOR POLYNOMIAL F(N)
This is the special case with a constant. It is the quickest form to apply when has no log factor.
Where this was asked: 2020 (1), 2022 (2), 2023 (2), 2024 (3), 2025 (2), 2026 (4). See the 14 previous-year questions on Complexity. This shows what was asked, not what will be asked.