Big-O, Omega and Theta notation, ordering functions by growth rate, counting loop iterations, solving recurrences with the master theorem and recursion trees, and measuring space including the recursion stack.
Before you start
Logarithms and exponents
Comparing growth rates mostly means taking logs and using rules like .
(upper bound) if there are constants and with for all .
(lower bound) if for all .
(tight bound) if both hold.
if ; if .
Useful properties:
All five are transitive. , , are reflexive; only is symmetric.
if and only if .
Limit test: if with , then .
Constant factors and lower-order terms do not matter: .
But constants in exponents do: is not , while is .
Worst-case complexity is the maximum cost over all inputs of size . GATE asks for it unless the question says average or best case.
2. Ordering functions by growth
The standard order, slowest growth first (each is of the next):
Tricks for unfamiliar functions:
Take logs. Compare and ; if then grows faster. For example , which beats every polynomial but loses to .
Any polylog loses to any polynomial: , though only for very large .
Any polynomial loses to any exponential: .
, so and .
Stirling: , and .
Log base does not matter inside : . It does matter in an exponent.
When comparing two functions, the limit of the ratio settles it; if the limit does not exist (for example ), they may not be comparable at all.
3. Counting loops and measuring space
Time is the number of times the innermost statement runs.
Loop pattern
Iterations
i = 1..n, step i++
i = 1; i <= n; i *= 2
i = n; i > 1; i = sqrt(i)
nested, j = 1..i inside i = 1..n
j steps by i up to n, inside i = 1..n
(harmonic)
j = 1..i inside i = 1, 2, 4, ..., n
, so
Useful sums: , , , and a geometric series is dominated by its largest term.
Space complexity counts memory as a function of . GATE usually means auxiliary space (beyond the input). Count:
arrays and other structures the algorithm allocates;
the recursion stack: depth of recursion times space per frame.
So recursive binary search uses stack space while the iterative one uses . Merge sort needs for merging. Naive recursive Fibonacci takes exponential time but only space, because the stack never holds more than frames.
4. Solving recurrences: master theorem and recursion tree
For with , , compare with :
Case
Condition
Result
1
for some
2
,
3
and for some
The master theorem does not apply to subtract-type recurrences. Use these instead:
; .
.
(substitute ).
Recursion tree: draw the cost of each level and add the levels. For each level costs and there are levels, so . For unequal splits like , every level costs at most and the depth is , giving .
Recursion tree for T(n) = 2T(n/2) + n: every level costs n, and there are about log n levels
Formulas to remember
Big-O
Theta
Master theorem critical exponent
Master theorem, case 2
Arithmetic sum
Harmonic sum
Stirling (log form)
Log-power swap
Common mistakes
Treating as tight: is true, but the tight bound is .
Dropping constants in exponents: is not , though is.
Applying the master theorem to or to cases where is not polynomially larger or smaller (use the extended case 2 or a recursion tree).
Forgetting the regularity condition in case 3.
Ignoring the recursion stack when asked for space complexity.
Assuming two nested loops always give ; a doubling inner loop gives , and an inner loop bounded by a doubling outer index gives .
Worked examples
Try each step yourself, then reveal the working.
Example 1: Arrange five functions by growth
numerical
Arrange in increasing order of asymptotic growth: , , , , .
Step 1: Simplify anything that hides a familiar function.
Try it on paper first.
Example 2: Counting a doubling inner loop
numerical
How many times does count++ run for , and what is the order in general?
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j = j * 2)
count++;
Step 1: Count the inner loop for $n = 16$.
Try it on paper first.
Example 3: Three master theorem cases
numerical
Solve (a) , (b) , (c) .
Step 1: (a) Find $n^{\log_b a}$ and compare with $f(n)$.
Try it on paper first.
Example 4: Do constants in the exponent matter?
conceptual
Is ? Is ?
Step 1: Rewrite $2^{n+1}$.
Try it on paper first.
Previous year questions
21 official GATE CSE questions on this topic, newest first.
10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.