3.1.6 · D3Complexity Analysis

Worked examples — Tight bounds — Θ notation; lower bounds — Ω notation

2,203 words10 min readBack to topic

This is the drill room for the parent topic. The parent gave you the definitions; here we run them through every kind of situation a problem can throw at you, one worked case per cell, so you never meet an unfamiliar shape in an exam.

Before we start, one reminder of the three definitions we are going to apply (never assume — always earn):


The scenario matrix

Every complexity-bound problem you will ever be asked is one of these cells. The examples below are labelled with the cell they close.

Cell What it tests Example
A. Polynomial + junk Drop lower-order terms, keep the top Ex 1
B. Ceiling holds, floor fails yes, no → strictly smaller () Ex 2
C. Floor holds, ceiling fails yes, no → strictly larger () Ex 3
D. Log / non-polynomial shapes , ranking Ex 4
E. The limit shortcut (all 3 outcomes: , finite, ) L'Hôpital-style test Ex 5
F. Degenerate / zero-ish input constant , , or Ex 6
G. No single exists best ≠ worst in order Ex 7
H. Word problem (real algorithm) translate code → → bound Ex 8
I. Exam twist (sum of unlike terms) vs , dominance Ex 9

We cover all nine. Signs never go negative here (running times are ), so our "quadrant" analogue is instead which term dominates and which of the ratio lands on — those are the branches we must exhaust.


Cell A — Polynomial with lower-order junk


Cell B — Ceiling holds, floor fails ()

Look at the ratio curve in the figure: it slides toward , never levelling off.

Figure — Tight bounds — Θ notation; lower bounds — Ω notation

Cell C — Floor holds, ceiling fails ()

The figure shows the polynomial ahead early, then the exponential blasting past.

Figure — Tight bounds — Θ notation; lower bounds — Ω notation

Cell D — Logarithmic / non-polynomial shapes


Cell E — The limit shortcut, all three outcomes


Cell F — Degenerate / near-zero inputs


Cell G — When NO single exists


Cell H — Word problem: bound a real loop


Cell I — Exam twist: sum of wildly unlike terms


Recall Quick self-test — cover the answers

Which cell: ::: (Cell A). Which cell: tells you? ::: not , i.e. (Cell C/E). Does insertion sort have one for its full runtime? ::: No — best , worst (Cell G). Class of a function that always costs steps? ::: (Cell F). Does the log base change the class? ::: No, (Cell D).


Connections