Upper, lower, and tight
After thiswhat you will be able to doBuild upper, lower, and tight bounds with multipliers and thresholds, and keep those bounds separate from best, worst, and average inputs.
Questionwhat this lesson answersO(f) only promises a cost grows no faster than f. What says it grows no slower, what says it grows at exactly the rate of f, and why is none of that the same question as best case versus worst case?
Not coveredwhat this lesson leaves outWe define the lower bound and the tight bound by mirroring the upper one, and we show the running polynomial sits at exactly n squared. We prove no specific lower bound from scratch, and we hold best, worst and average case for the lesson on recurrence relations.
The lesson on what O(f) actually is gave a cost a ceiling: a fixed multiple of another rule used for comparison, called a comparison rule, that stays above the cost once the input is large enough. That is what says. Its full membership test, and the two witnesses it asks you to produce, live behind the What O(f) actually is door. A ceiling of this kind is called an upper bound. It answers only half of the question. A very low cost can sit below it too.
Imagine putting a second line under the cost. This line is also a fixed multiple of the same comparison rule, but the cost must stay above it after some starting input. That lower line is a floor. A floor of this kind is called a lower bound. The collection of functions with such a floor is called , read “Omega of f”. Its definition reverses the direction of the final comparison:
The same two kinds of witness appear. A positive multiplier sets the floor’s height, and a threshold says where the floor must remain below the cost. This lower statement is about one cost rule. It is not yet a claim that every possible algorithm must do at least this much work. The harder claim is what the Lower bound proofs door is for.
Put a ceiling and a floor around the cost, both made from the same comparison rule. If the cost cannot escape above the first or below the second after one shared starting point, its rate has been pinned from both sides. A two-sided bound of this kind is called a tight bound. Its symbol is , read “Theta of f”. It means membership in both collections:
The word tight describes the fit between the two multiples. It does not say the two curves touch, or that either multiple is unique. It says they have the same comparison shape and trap the cost between them for all sufficiently large inputs.
The running cost between two curves
Use the familiar comparison rule and the familiar cost rule:
For the ceiling, the lesson on what O(f) actually is already found the first witness pair. Give the ceiling multiplier the name . With , the cost stays at or below four copies of from input onward:
For the floor, give its multiplier the name . Choose . The extra linear and fixed pieces are positive for every positive input, so the floor works immediately:
The two statements can share the later threshold. From onward the cost is enclosed:
That gives a ceiling witness with threshold , and a floor witness with threshold . Since both comparison shapes are , the cost belongs to . The floor is easy in this example because the discarded pieces are positive. The ceiling has to wait for them to become small compared with the quadratic piece.
Start with the ceiling
Begin with the ceiling multiplier at four. This is the same upper witness from the previous lesson, before a floor has been added to it.
Two-sided bounds
Watch the cost get pinned from both sides
The solid accent curve is the ceiling. The dashed accent curve is the floor. Once both are valid, the shaded region is the stretch where the cost must remain between them.
- Cost
- Ceiling
The vertical marker names the first input where both witness statements can be true. Moving the ceiling closer to the cost makes that marker travel right.
- Current c one
- 4.0
- Current c two
- 3.0
- Ceiling witness
- From 538
- Floor witness
- From 1
- Both bounds
- Yes, from 538
The floor is hidden in this step. The ceiling witness is still available below.
The island also shows why a tighter ceiling can require more patience. Move its ceiling multiplier closer to the coefficient on the highest-power piece, the leading coefficient. The gap around the cost narrows, but the threshold moves to a larger input. A tight bound is not a claim that you found the closest possible lines. It is the claim that some fixed pair works.
A different question from cases
There is a separate source of confusion. The symbols , , and describe how one chosen cost function, a rule that assigns a step count to each input size, changes as the input grows. They do not choose which input a program receives. For a fixed size, some inputs can let a program stop quickly and others can make it keep working. The input that gives the fewest steps is called a best-case input. The one that gives the most steps is called a worst-case input. An average-case cost takes an average over inputs, which also requires saying how likely each possible input is.
These are separate questions, or separate axes of description. You can ask for an upper bound on the best-case cost, a lower bound on the worst-case cost, or any other pairing. Hearing “worst case” should not make you think , and hearing “best case” should not make you think . The first pair of words chooses an input from a size class. The second pair compares the resulting cost rule with a growth shape.
Consider a program that checks a list whose items have no order, called an unsorted list, from the first item onward until it finds a target. When the target is first, it makes one check. Its best-case cost is , and it also has the matching lower statement . When the target is last, it makes one check for each item. Its worst-case cost is , and it also has the matching lower statement . The two facts use both axes at once without identifying them. The Best, worst, and average door untangles the cases fully.
When you can show both walls around a chosen cost, is the honest description of its rate. alone is only a ceiling, and it might be loose. The upper-bound definition is behind the earlier door; the next door takes up the input choices that bounds do not make for you.
Doorswhat to read next, and why
- What O(f) actually isThis lesson mirrors the membership test of the upper bound to build the other two. That test, with its two witnesses, is built there.
- Best, worst, and averageThis lesson insists the upper bound is a different axis from the worst case. How the two axes combine, and how they get confused, is the lesson on recurrence relations.
- Lower bound proofsNaming a lower bound is easy. Proving that no algorithm at all can beat a given rate is hard, and this lesson does not attempt it.
Symbolswhat each one means, and whether we defined it, measured it, or just started there
- O(f)Status: door
- the upper bound, the set of functions that eventually grow no faster than a fixed multiple of f
- Omega(f)Status: defined
- read "omega of f", the lower bound, the set of functions that eventually grow no slower than a fixed multiple of f
- Theta(f)Status: defined
- read "theta of f", the tight bound, the functions that belong to O(f) and Omega(f) at the same time
- c_1, c_2Status: defined
- the two witness multiples, one holding the ceiling above the cost and one holding the floor below it
- n_0Status: defined
- the shared threshold, the input size from which both the ceiling and the floor are required to hold
What these classifications mean
- defined
- circular by construction, true because we chose it
- empirical
- a measured claim about the world that could have come out otherwise
- bottoms out
- a primitive of the model, with nothing under it here
- door
- used here, explained elsewhere