The floors

A floor one pass cannot get under

An exact one-pass selector must reach a different memory state for every prefix it might have read, and the pigeonhole that proves it is small enough to perform — nine hundred and twenty-four prefixes through a nine-bit state, the collision produced, the suffix that separates it, and two true medians it cannot both return. Ten bits collide on none, so the bound is exact — and a second pass walks under it by a factor of ninety.

This collection has five lower-bound arguments and this is the sixth. Three of them are now of the same kind — a counting argument on memory states — and it is worth saying what makes each different, because the family looks uniform from a distance and the constructions are not.

The floor under exact distinct counting separates two prefixes by appending a single item. The floor under a window separates them the same way and is tidier, because a window is the state. This one needs a suffix built for each pair, and the reason is that selection’s answer does not move when one item is appended.

The construction

Fix a universe [0,u)[0, u) and let the prefix be some hh-subset AA of it. Follow it with a suffix of h1h - 1 sentinels — (hc)(h - c) of them below every element of the universe and (c1)(c - 1) above every element — so the stream has length 2h12h - 1 and its median is exactly the cc-th smallest element of AA.

That is the whole device: the sentinels are a rank shift, chosen so that the fixed question “what is the median” reads out the order statistic of interest.

Now take two distinct subsets ABA \ne B and let dd be the smallest element on which they differ, say dABd \in A \setminus B. Let c=A[0,d]c = |A \cap [0, d]|. Then:

  • the cc-th smallest of AA is dd, because AA has exactly cc elements at or below dd and dd is the largest of them;
  • the cc-th smallest of BB is strictly larger, because AA and BB agree below dd and BB is one short there.

Choose the suffix for that cc and the two streams have different medians while sharing everything after the prefix. An algorithm in the same memory state after both prefixes reads the same suffix, performs the same computation, and emits the same number — so it is wrong on one of them.

Every hh-subset therefore needs its own state, and the state needs at least log2(uh)\log_2 \binom{u}{h} bits.

Performed, not quoted

(126)=924\binom{12}{6} = 924, so log2924=9.85\log_2 924 = 9.85 bits, so nine bits cannot be enough. That is small enough to check by exhaustion rather than by argument, and this collection’s standing preference is to check.

The pigeonhole, performed: 924 prefixes through a 9-bit stateEvery 6-subset of a universe of 12 is fed to a candidate one-pass selector that keeps 9 bits, and the collision the counting argument requires is produced rather than asserted. The two prefixes shown reach the same state. They first differ at 3, which is in the first and not the second, so the first has 4 elements at or below it and the second has 3. Appending -1, -2, 12, 13, 14 — 2 sentinels below everything and 3 above — makes each stream 11 long with its median at the 4th smallest of its prefix. Those medians are 3 and 4. The candidate is in the same state and reads the same suffix, so it answers the same number and is wrong on one of them. At 10 bits — which is ⌈log₂ C(12,6)⌉ = ⌈9.85⌉ — no collision exists, so the bound is exact and not merely a bound.universe 0…11 · prefixes of 6 · candidate keeps 9 bitsthe two prefixes that collideA01234567891011B01234567891011first differencesame state — the candidate stores "7" after boththen both read the same suffix -1, -2, 12, 13, 14true median of A3true median of B4and one answer for both924 prefixes · floor ⌈log₂ C(12,6)⌉ = 10 bits10 bits collide on none
Fig. 1 The collision, produced. Every one of the 924 prefixes is fed to a candidate that keeps nine bits, two of them come back in the same state, and the essay’s construction turns that into a refutation: the first difference, the suffix, and the two true medians the candidate cannot both give.

The witness on that plate is worth reading in full because it is the whole argument made concrete.

  • A={0,1,2,3,4,7}A = \{0, 1, 2, 3, 4, 7\} and B={0,1,2,4,8,11}B = \{0, 1, 2, 4, 8, 11\}.
  • They first differ at 3, which is in AA and not in BB.
  • AA has four elements at or below 3, so c=4c = 4.
  • The suffix is {1,2}\{-1, -2\} below everything and {12,13,14}\{12, 13, 14\} above it: two low sentinels and three high ones, eleven items in all.
  • The median of AA plus the suffix is 3. The median of BB plus the suffix is 4.
  • The candidate is in the same state after both prefixes and reads the same suffix. It answers one number.

There is nothing left to argue about. It is a complete refutation of a specific candidate rather than an existence claim about all of them, and it is what “performed rather than quoted” means here.

And it is tight

A bound that says nine bits are not enough is not, on its own, evidence that ten are. So the same exhaustion is run the other way.

candidate state bits collides?
colex rank of the subset 9 yes
colex rank of the subset 10 no — 924 distinct states
bitmap of the first ten elements 10 yes
bitmap of the first eleven elements 11 no

Ten bits, which is 9.85\lceil 9.85 \rceil, distinguish all 924 prefixes. So the counting argument is not merely a bound; it is the answer.

The third row is the interesting one and it is why the bitmap is on the plate. An encoding a stream can actually maintain costs an extra bit here. The colex rank is the information-theoretic optimum and updating it as items arrive is not a one-line operation; a bitmap is trivial to maintain and needs eleven bits for the same job, because it wastes the states corresponding to subsets of the wrong size.

That gap is small and it is real, and it is the same distinction this collection draws elsewhere between what a bound permits and what a structure can be built to reach.

The pigeonhole, performed: 924 prefixes through a 8-bit stateEvery 6-subset of a universe of 12 is fed to a candidate one-pass selector that keeps 8 bits, and the collision the counting argument requires is produced rather than asserted. The two prefixes shown reach the same state. They first differ at 3, which is in the first and not the second, so the first has 4 elements at or below it and the second has 3. Appending -1, -2, 12, 13, 14 — 2 sentinels below everything and 3 above — makes each stream 11 long with its median at the 4th smallest of its prefix. Those medians are 3 and 4. The candidate is in the same state and reads the same suffix, so it answers the same number and is wrong on one of them. At 10 bits — which is ⌈log₂ C(12,6)⌉ = ⌈9.85⌉ — no collision exists, so the bound is exact and not merely a bound.universe 0…11 · prefixes of 6 · candidate keeps 8 bitsthe two prefixes that collideA01234567891011B01234567891011first differencesame state — the candidate stores "212" after boththen both read the same suffix -1, -2, 12, 13, 14true median of A3true median of B4and one answer for both924 prefixes · floor ⌈log₂ C(12,6)⌉ = 10 bits10 bits collide on none
Fig. 2 The same search with a candidate two bits under the floor rather than one, where the collision is found sooner and the witness is a different pair. The construction does not care how far under the floor the candidate is; it cares that the pigeonhole applies.

One size proves one size, and the argument is about a family. The same exhaustion runs at any universe small enough to enumerate, so it is run twice more — once smaller and once larger — and the point of doing so is that the floor is log2(uh)\lceil \log_2 \binom{u}{h} \rceil at every one of them, computed rather than fitted.

The pigeonhole, performed: 252 prefixes through a 7-bit stateEvery 5-subset of a universe of 10 is fed to a candidate one-pass selector that keeps 7 bits, and the collision the counting argument requires is produced rather than asserted. The two prefixes shown reach the same state. They first differ at 2, which is in the first and not the second, so the first has 3 elements at or below it and the second has 2. Appending -1, -2, 10, 11 — 2 sentinels below everything and 2 above — makes each stream 9 long with its median at the 3th smallest of its prefix. Those medians are 2 and 3. The candidate is in the same state and reads the same suffix, so it answers the same number and is wrong on one of them. At 8 bits — which is ⌈log₂ C(10,5)⌉ = ⌈7.98⌉ — no collision exists, so the bound is exact and not merely a bound.universe 0…9 · prefixes of 5 · candidate keeps 7 bitsthe two prefixes that collideA0123456789B0123456789first differencesame state — the candidate stores "3" after boththen both read the same suffix -1, -2, 10, 11true median of A2true median of B3and one answer for both252 prefixes · floor ⌈log₂ C(10,5)⌉ = 8 bits8 bits collide on none
Fig. 3 And at a smaller universe: 252 prefixes, a floor of ⌈log₂ 252⌉ = 8 bits, and a seven-bit candidate that collides. The construction scales down as well as it scales up, which is the check that it is not an artefact of one size.
The pigeonhole, performed: 3,432 prefixes through a 11-bit stateEvery 7-subset of a universe of 14 is fed to a candidate one-pass selector that keeps 11 bits, and the collision the counting argument requires is produced rather than asserted. The two prefixes shown reach the same state. They first differ at 3, which is in the first and not the second, so the first has 4 elements at or below it and the second has 3. Appending -1, -2, -3, 14, 15, 16 — 3 sentinels below everything and 3 above — makes each stream 13 long with its median at the 4th smallest of its prefix. Those medians are 3 and 4. The candidate is in the same state and reads the same suffix, so it answers the same number and is wrong on one of them. At 12 bits — which is ⌈log₂ C(14,7)⌉ = ⌈11.74⌉ — no collision exists, so the bound is exact and not merely a bound.universe 0…13 · prefixes of 7 · candidate keeps 11 bitsthe two prefixes that collideA012345678910111213B012345678910111213first differencesame state — the candidate stores "4" after boththen both read the same suffix -1, -2, -3, 14, 15, 16true median of A3true median of B4and one answer for both3,432 prefixes · floor ⌈log₂ C(14,7)⌉ = 12 bits12 bits collide on none
Fig. 4 And up: 3,432 prefixes and a floor of twelve bits. The exhaustion is over (uh)\binom{u}{h} subsets, which is why this argument is demonstrated at small sizes and stated at large ones — the search is exponential in exactly the quantity the bound is about.

What the bound says, at scale

For a stream of nn values drawn without repetition from a universe of uu, the same argument with h=n/2h = n/2 gives

log2(un/2)  =  Ω(n)\log_2 \binom{u}{n/2} \;=\; \Omega(n)

whenever uu is a constant factor above nn — which is Θ(n)\Theta(n) bits, and for thirty-two thousand thirty-two-bit values is on the order of a million.

That is not “keep the stream” as an upper bound; it is “keep something the size of the stream” as a lower one, and the two are close enough that the one-pass problem is settled. An exact one-pass selector is not a summary and cannot be made into one.

Why appending one item is not enough

The difference between this construction and its two siblings is one sentence and it is the interesting part of the essay, so it is worth doing slowly.

For distinct counting, take two half-sized subsets STS \ne T reaching the same state, pick xSTx \in S \setminus T, and append it. The true counts are then S|S| and T+1|T| + 1, which differ by one. One item, no computation, done.

For a window, take two distinct windows of length WW differing first at position dd and feed WdW - d zeros. The windows then agree everywhere except at dd, so their counts differ by exactly one. A little more work, still a suffix that depends only on dd.

For selection, appending one item does almost nothing. The median of a set and the median of that set plus one element are usually equal or adjacent, and — crucially — they are equal or adjacent for both SS and TT. The answer is a value in the middle of the data and it is insensitive to what happens at the edges, which is exactly the property that makes a median useful and exactly what blocks the easy separation.

So the suffix has to do something else: it has to move the question. The sentinels do not add information about the prefix; they shift which order statistic the fixed query reads out, and they shift it to the one position where AA and BB are known to differ. The construction is therefore a small reduction — from “distinguish these two prefixes” to “ask the median about rank cc” — rather than a direct appeal.

That reduction is what costs h1h - 1 extra items, and it is the reason this floor is stated for a stream of length 2h12h - 1 over a universe of uu rather than for a stream of length hh. The bound is log2(uh)\log_2\binom{u}{h} bits for a stream of 2h12h-1 items, which is still Θ(n)\Theta(n) and is a constant factor weaker than the arithmetic would suggest if the sentinels were free.

And a second pass walks under it

Which is the reason this floor is in the same group as the two multi-pass essays rather than beside the others.

state
one pass, exact, floor ~1,000,000 bits
two passes, exact, measured 11,712
nine passes, exact, measured 320

A factor of ninety at two passes and three thousand at nine, against a bound that is not loose — the tightness check above says the one-pass number cannot be improved by more than an encoding’s worth.

The reason the argument does not survive is exactly where it uses the model. The pigeonhole is over the states an algorithm can be in after reading a prefix, and it depends on the algorithm never seeing that prefix again. A two-pass algorithm reads it twice; the state after the first pass no longer has to determine the answer, only to determine what the second pass should look for; and the second pass supplies everything the state threw away.

A lower bound is a statement about a model, and this one names its model in a single clause. That is the same lesson as the essay on turnstiles, arriving in a place where the clause is a number rather than a property of the data.

Peak state against passes, for two splitting rules on two distributionsExact selection of the 0.5 quantile of 32,768 values, in p passes, with the state measured at its peak during the run. Every point is an exact answer — a run that returned anything else stops the build — so the vertical axis is the price of exactness rather than a price paid for being approximately right. The line at the top is what one pass costs: 1,048,576 bits, because an exact one-pass selector has to keep the stream, and the floor under that is a counting argument this collection performs rather than quotes. The equal-width rule needs no knowledge of the data and gets 37 times smaller as passes are added — on data spread evenly. On a heavy tail it collapses, because an equal-width cut of a range containing almost no data narrows the range and not the count; the sampled rule, which spends half its passes finding out where the data is, is barely affected. Both axes are logarithmic.10³10⁴10⁵10⁶passes over the datapeak bits of stateone pass, exact: 1,048,576 bitsradix, uniformsample, uniformradix, paretosample, paretoevery point exact · 32,768 values320 bits at best
Fig. 5 The measured curve, with the one-pass cost drawn as the line at the top. Every point below that line is a run that got under a bound this essay proves, by taking a resource the bound assumed away.

What is quoted rather than performed

The pp-pass version of the bound is not demonstrated here and it is worth being exact about which part is missing.

Munro and Paterson proved in 1980 that pp-pass selection in a comparison-based model requires Ω(n1/p)\Omega(n^{1/p}) storage. The measurements in the previous essay sit on that shape — the fitted exponent is 13.5 against a predicted 15, over a range of thirty-six times — and sitting on a shape is not a demonstration of a bound. It is a prediction being met.

The argument itself is an adversary argument over comparison outcomes, and the smallest instance that would demonstrate anything is far past what an exhaustive search can walk: the one-pass case above needs (126)=924\binom{12}{6} = 924 subsets and the two-pass case would need to quantify over every possible pair of state maps as well.

So this collection has, on this question:

  • the one-pass floor, performed — the pigeonhole run to exhaustion, the collision produced with its witness, and the tightness checked from both sides;
  • the multi-pass floor, quoted — stated with its author, marked as quoted, and not drawn under any measured curve;
  • and the gap between them, measured — the factor of ninety above.

That is the same division the conditional floor makes between a link performed and a link quoted, and it is made for the same reason: a plate that put a quoted bound under a measured curve would be presenting a citation as a demonstration.

Peak state against passes, for two splitting rules on two distributionsExact selection of the 0.5 quantile of 32,768 values, in p passes, with the state measured at its peak during the run. Every point is an exact answer — a run that returned anything else stops the build — so the vertical axis is the price of exactness rather than a price paid for being approximately right. The line at the top is what one pass costs: 1,048,576 bits, because an exact one-pass selector has to keep the stream, and the floor under that is a counting argument this collection performs rather than quotes. The equal-width rule needs no knowledge of the data and gets 37 times smaller as passes are added — on data spread evenly. On a heavy tail it collapses, because an equal-width cut of a range containing almost no data narrows the range and not the count; the sampled rule, which spends half its passes finding out where the data is, is barely affected. Both axes are logarithmic.10³10⁴10⁵10⁶passes over the datapeak bits of stateone pass, exact: 1,048,576 bitsradix, uniformsample, uniformevery point exact · 32,768 values320 bits at best
Fig. 6 The same measurements with only the distribution the bound is about on them, so nothing on the plate is a statement about skew. The one-pass line is the floor; the curve is what passes buy; and the space between them is not annotated with a bound, because there is not one here to draw.

The suffix has to depend on the pair

There is a quiet quantifier in the construction and it carries most of the bound’s strength, so it is worth pulling out and pricing.

The suffix is built after the pair is chosen: cc is computed from the first element on which AA and BB differ, and a different pair generally needs a different cc. Nothing in the argument produces one stream that is hard. It produces a family, and for each colliding pair somewhere in the family there is a suffix that separates that pair.

Ask what the same pigeonhole proves if the suffix is fixed in advance — one cc, one set of sentinels, chosen before the algorithm is. Two prefixes then need different states only when they give different answers to that one question, and the number of distinct answers is at most the size of the universe. The floor collapses to log2u\lceil \log_2 u \rceil:

universe, prefix prefixes floor, suffix chosen per pair floor, one fixed suffix
u=10u = 10, h=5h = 5 252 8 bits 4 bits
u=12u = 12, h=6h = 6 924 10 bits 4 bits
u=14u = 14, h=7h = 7 3,432 12 bits 4 bits

Six of the ten bits in the demonstrated floor are bought by letting the suffix vary, and the share grows with the universe — the left column climbs like log2(uh)\log_2\binom{u}{h} and the right one is stuck at log2u\log_2 u, because a fixed question has only as many answers as there are values to give.

So the adversary here is adaptive in a specific and limited sense. It does not watch the algorithm run and it does not choose values in response to comparisons, which is what an adversary does in the argument that hides an edge. It reads the algorithm’s state map once, finds two prefixes that land in the same state, and only then writes the ending. That is weaker than a running adversary and enough for this bound, and it is worth naming because a reader who has met the edge-hiding argument will otherwise import the stronger machinery and wonder where it is used.

It also settles a question the plates invite. There is no single stream on which every nine-bit selector fails — each of the 924 prefixes is an ordinary six-element walk and any one of them can be handled in nine bits by a candidate built for it. The hardness is a property of the set, which is why the plate names a pair and a suffix rather than an input.

A floor the trivial algorithm already meets

Most floors on this site leave room. The comparison-sorting floor is a target that real sorts approach and do not reach, and the size of the remaining gap is interesting enough to have its own essay. The distance is where engineering lives: a better merge policy, a better pivot, a better cutoff, each recovering a little of it.

This floor has no such room, and the tightness check above is what says so.

candidate bits note
the floor 10 log2924\lceil \log_2 924 \rceil
colex rank of the subset 10 meets it exactly
bitmap over the universe 12 the obvious implementation, 20% over

The dumbest correct thing — remember which values have arrived — is two bits above a bound that no cleverness can improve. A floor that the naive algorithm already matches is not an invitation to optimise; it is a statement that the problem as posed is finished, and reading it as the first kind is how effort gets spent on a constant that is not there.

What follows from that is the shape of the rest of the field. When a bound is tight against the trivial algorithm the only moves left are to change what is being asked, and there are exactly three of them here, each measured elsewhere on the site:

The three exits are not equally cheap and the site’s numbers say which is cheapest: a second pass is a factor of ninety and costs one more read, while a tolerance buys unbounded savings and costs an answer that can be wrong. Nothing on the list is a better one-pass exact selector, because the row above says there is not one.

The six floors, and what kind each is

Worth collecting, because this is the sixth and the family has become various enough that “there is a floor” no longer says what sort of thing is meant.

what is bounded argument performed here?
comparison sorting counting, on decision trees yes — log2n!\log_2 n! exactly
connectivity adversary, on edges examined yes
exact distinct counting counting, on memory states yes
exact windowed counting counting, on memory states yes
exact one-pass selection counting, on memory states yes — this essay
edit distance conditional, on a conjecture half — one link performed, one quoted

Three of the six are the same argument with a different separating construction, and the constructions are where the work is. Appending one item separates two distinct-count prefixes and two window prefixes; separating two selection prefixes needs a suffix computed from the pair.

Why the floor is log₂(n!): four elements need five comparisonsEach internal node is one comparison and has two outcomes, so a run of the algorithm is a root-to-leaf path and the path's length is that run's comparison count. Every one of the 24 orderings of 4 elements must arrive at its own leaf, or two inputs needing different answers would receive the same one. The deepest tree on the left has 16 leaves. Eight orderings, in red, have nowhere to go — so no comparison sort of four elements can always finish in four comparisons, and the floor is ⌈log₂ 24⌉ = 5.every algorithm that makes at most 4 comparisonsthe 24 orderings of 4 elementsroot16 leaves16 seated · 8 with no leafone comparison per level, two outcomes per comparison⌈log₂(4!)⌉ = 5 comparisons
Fig. 7 The first of them, from the foundation: a decision tree that cannot be deep enough, because it must have a leaf for every ordering. Every floor in the table is this argument with the leaves replaced by something else — outcomes, then subsets, then windows, then prefixes.

The floor is on the state and not on the work

One more thing the bound does not say, and it is the sort of omission that gets read as a claim.

Nothing above constrains how much computation a one-pass selector does. The pigeonhole counts the states an algorithm can be in between items and says there must be many of them; it is indifferent to what happens inside a step, and an algorithm allowed unbounded time per arrival is bound by exactly the same number. So the floor is a memory statement in the strict sense, and the two resources this collection usually reports together come apart here.

That is not a technicality on a stream. The selector that meets the floor by holding a colex rank has to update that rank as each item arrives, which is a genuine computation over the whole encoded subset; the bitmap two bits above it updates in one instruction. The encoding that reaches the bound is the expensive one to maintain, and the two extra bits buy a per-item cost that does not grow with what has been seen. That trade — a little more state for far less work per arrival — is the same one the sampling that goes the other way makes in an index, and it is invisible to any bound that counts only bits.

What is not measured here

Repetitions. The construction uses subsets, so every value in the prefix is distinct. A stream with repeated values has fewer distinguishable prefixes and a correspondingly lower floor, and none of the arithmetic here covers it.

Approximate selection. Everything above is about exactness. An approximate median is available in one pass and very little state, and there is a separate floor under that — it is a statement about ε\varepsilon rather than about nn, and this collection has several of those.

Randomised algorithms. The pigeonhole applies to deterministic algorithms. A randomised one has a distribution over states and the argument needs the usual repair, which is not made here — so the bound as demonstrated is a deterministic one, and every algorithm measured against it is deterministic too.

A measured sort against the floor under every sortThe lower line is (n/B)·log_{M/B}(n/B), which is a lower bound on the transfers any algorithm needs to sort n elements in this model — not a bound on merge sorts, on all of them. The upper line is a real external merge sort, counted. The ratio runs from 2.29 to 3.20: the algorithm is within a constant of optimal, and the constant is the part the notation drops.10⁴10010³n (elements)block transfersmeasured sortthe bound3.20×2.67×2.29×2.94×2.67×B = 32, M = 512 (M/B = 16)3.20× the floor at worst
Fig. 8 A floor in the model where a pass is the unit, from the external-memory field: what sorting costs against what nothing can sort for less, in block transfers. It is the closest neighbour this bound has — a floor stated in reads rather than in bits — and putting the two together is what a full account of a multi-pass algorithm would need.

What this makes readable

Essays that name this one as a prerequisite.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

What links here

Every essay whose body links to this one.

The objects this essay names

Each one links to every other essay that touches it.

AdversaryComplexity classCounting argumentHonest limitLower boundMeasurementModelMulti-passPigeonholeSelectionState bitsStreaming model