Sets and membership
After thiswhat you will be able to doRead T in O(n squared) as a membership claim, compare growth classes by subset, and show why an upper bound can be true but loose.
Questionwhat this lesson answersThe O(f) lesson called O of n squared a set of functions and wrote that a cost belongs to it, leaning on the words set and belongs as if they were obvious. What is a set, what is it for a thing to belong to one, and why do the growth classes nest inside each other?
Not coveredwhat this lesson leaves outWe build the set machinery the O(f) lesson assumed and show the growth classes nesting. We do not develop the axioms of set theory, and we do not count how many functions a class contains.
The What O(f) actually is lesson made a move that was easy to read past. It called a set of functions and wrote that a cost belongs to it. Those words did real work, but the lesson was busy earning a different claim: the two witnesses that make an upper-bound test true. What is the collection here? What is one thing inside it? What does it mean to say that a cost passes from outside to inside?
Start with an ordinary act of sorting. You put several things behind one label and decide, with a rule, which things count. A collection treated as one object in that way is called a set. The rule is not optional. A bag of names on a page becomes a mathematical set only when there is a definite answer to the question, “does this thing count?”
One thing selected by that rule is called an element. The relation between one element and the set that contains it is called membership. The belongs-to sign is . A short claim such as says that the cost rule is one of the functions selected by the rule for . It is not loose talk about a cost being roughly nearby. It says the cost passes a particular test.
A compact notation makes the rule visible. Begin with possible things called , then keep the ones for which a stated condition is true. This way of writing a rule is called set-builder notation:
Read it as “the x such that the condition holds.” The braces make one collection. The part after the colon is its gatekeeper. Change the condition and you have changed the set, even if the same letter appears before the colon.
That is exactly the structure hidden in the earlier upper-bound definition. Its set starts with possible cost functions and keeps the ones for which two witness numbers make the ceiling hold from some threshold onward. Writing
means checking against that condition. The multiplier and starting input built in the What O(f) actually is lesson are the witnesses for this membership test. “Belongs to” is therefore a claim with a receipt, not a vague replacement for an equals sign.
One collection inside another
Now compare two collections. Suppose every thing admitted by the first rule is also admitted by the second. The first collection sits wholly inside the second. A set in that position is called a subset, written with a contained-in sign:
The sign says that every element of is also an element of . It does not say the two sets have exactly the same elements. If the second one has at least one extra element, the first sits strictly inside it. That stronger kind of containment is called a proper subset, and its sign is the contained-in sign crossed by a stroke, .
The growth classes from the arc have this structure. Take a cost with a straight-line ceiling, meaning one that is at most a fixed multiple of . The same multiplier also makes a square ceiling work once the input is at least one, because
So every function in is also in . The first class is a subset of the second. The same move repeats along the familiar family of ceilings:
Read the chain from left to right, each shape fitting beneath the next ceiling. A fixed amount is eventually below any multiple of a repeated-cut count. That repeated-cut count is eventually below a straight line. A straight line fits beneath one straight-line pass on each repeated-cut level. That combined ceiling fits beneath a square, and a square fits beneath a cube. At each step the ceiling on the right grows faster, so it can cover every function already covered by the slower ceiling on the left. The definition of gives each statement room to choose a threshold and a fixed multiplier.
Every containment shown is proper. The function belongs to , but it cannot belong to . No matter which fixed multiplier is chosen, the square passes its straight-line ceiling once the input is larger than that multiplier:
The same kind of counterexample separates every neighboring pair: a repeated-cut count is not fixed, a straight line is not bounded by repeated cuts, and so on. The boxes are genuinely getting bigger, not merely acquiring different names.
Start in the innermost box
A rule that always returns five has the same output at every input. This unchanging rule is called a constant function. It sits in the innermost box and every box around it.
Membership map
Put each rule in its first fitting class
A box sits inside every larger box. Choosing a rule places it in the smallest box that contains it, then makes every outward membership visible at once.
The drawing is a membership picture, not a graph of the numerical values. Crossing one box boundary outward never removes a membership already earned inside it.
- Chosen function
- 5
- Smallest class
- O(1)
- Classes that contain it
- O(1), O(log n), O(n), O(n log n), O(n^2), O(n^3)
5 first belongs to O(1) and remains in every larger class.
This nesting explains why an upper bound can be true and still unhelpful. Saying a cost is also says something true about any cost that lives in , , or . It supplies a ceiling, but it may leave a great deal of empty space above the cost.
For a cost that matches one of these named shapes, the smallest class in the chain is the useful one. Calling that rate tight means no smaller class in this displayed chain still contains the cost. The Upper, lower, and tight door gives that idea its full two-sided test, with a floor as well as a ceiling. Here the point is simpler: a loose upper bound is possible because classes are sets, and these sets nest.
Doorswhat to read next, and why
- What O(f) actually isThat lesson used a set of functions and a membership test without building either. This lesson supplies the machinery it assumed.
- Upper, lower, and tightThe nesting of growth classes is why an upper bound can be loose: a cost in O(n) also sits in O(n squared). That lesson's tight bound is the case where no smaller class contains the cost.
Symbolswhat each one means, and whether we defined it, measured it, or just started there
- a setStatus: defined
- a collection of things treated as one object, fixed by a rule that decides what belongs
- an elementStatus: defined
- one of the things a set contains
- membershipStatus: defined
- the relation between an element and a set that contains it, written with the belongs-to sign
- a subsetStatus: defined
- a set all of whose elements also belong to a second set, so the first sits inside the second
- a proper subsetStatus: defined
- a subset that is strictly smaller than the set containing it, missing at least one of its elements, written with the contained-in sign crossed by a stroke
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