The floors

The adversary who hides the edge

The floor under comparison sorting comes from counting outputs — n! of them, so log₂(n!) comparisons. Connectivity has two outputs, so the same argument gives a floor of one comparison, which is useless. A different kind of argument gives Ω(E), and having both on the site is the point: lower bounds are not one technique.

The floors field has had exactly one technique in it. Count the possible answers, observe that each comparison distinguishes at most two cases, conclude that no algorithm can finish in fewer than log2(answers)\log_2(\text{answers}) comparisons. For sorting there are n!n! answers and the bound is log2(n!)\log_2(n!), and merge sort comes within a couple of percent of it.

Ask whether a graph is connected. There are two possible answers.

log22=1\log_2 2 = 1. The counting argument says: at least one comparison. It is a correct bound and it is worthless, and the reason it is worthless is instructive — the argument’s power comes entirely from the output space being large, and here the output space is a single bit.

So either connectivity is genuinely easy, or a different kind of argument is needed. It is the second, and the argument is one of the most elegant things in the subject.

Why connectivity cannot be decided without looking at every edgeTwo graphs on 8 vertices that differ in one edge. Any algorithm that has not examined that edge has seen exactly the same thing in both cases and must give the same answer, and the answers differ — the left graph is connected and the right is not. An adversary who watches which edges have been examined can always arrange for the undecided edge to be one of them, so every correct algorithm examines all E of them. This is a lower bound with nothing counted in it: it comes from what the algorithm has not seen.with the edge — connected01234567all 8 edges presentwithout it — two components01234567one edge withheld, everything else identicalV = 8, E = 8Ω(E), by adversary rather than by counting
Fig. 1 Two graphs on eight vertices differing in one edge. Any algorithm that has not examined that edge has seen identical information in both cases and must answer the same way in both — and the correct answers differ. The bound follows immediately, and nothing was counted to get it.

The argument

Suppose an algorithm claims to decide connectivity while examining fewer than all EE possible edges. Play against it.

The algorithm asks: “is there an edge between uu and vv?” The adversary answers, but the adversary is not holding a graph — it is holding a set of graphs consistent with everything it has said so far, and it answers whichever way keeps that set large and, critically, keeps it containing both a connected graph and a disconnected one.

The algorithm eventually stops and announces an answer. It has not examined some pair (x,y)(x, y). The adversary now produces two graphs: one that agrees with every answer given and has the edge xyxy, and one that agrees with every answer given and does not. The algorithm behaved identically on both, because it never asked about the only place they differ. Its answer is wrong on one of them.

Therefore no correct algorithm can stop early: every correct connectivity algorithm examines every edge slot. The bound is Ω(E)\Omega(E), and for the dense case, where the algorithm is asking about pairs of vertices rather than reading a list, it is Ω(V2)\Omega(V^2) — the property is evasive, meaning every single pair must be probed in the worst case.

Nothing in that argument counts anything. There is no logarithm, no entropy, no decision tree. The bound comes from what the algorithm has not seen.

Why the two techniques are so different

Set them side by side, because having only one on the site made lower bounds look like a single trick.

Decision tree. A bound on information. Each step of the algorithm yields at most one bit; the answer requires log2N\log_2 N bits; therefore log2N\log_2 N steps. It is a bound on how fast an algorithm can narrow down, and it is strong exactly when the answer space is large.

Adversary. A bound on coverage. The adversary keeps the answer undetermined for as long as the algorithm leaves any input unexamined; therefore the algorithm must examine everything. It is a bound on how much an algorithm can skip, and it is strong exactly when a single unexamined input can flip the answer.

The two are close to opposites in the situations they suit. Sorting has an enormous answer space and no single comparison can flip the whole answer, so counting works and an adversary gains nothing. Connectivity has a two-element answer space and one edge can flip it, so the adversary works and counting gains nothing.

Most interesting problems have neither property cleanly, which is why lower bounds are rare. For a great many, the best known bound is still the trivial “the input has to be read”.

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. 2 The technique that does not work here, drawn on the problem it does work on. Each internal node is a comparison and each leaf an ordering, so the tree’s depth is bounded below by the logarithm of its leaf count. For connectivity the equivalent tree has two leaves and the bound it gives is one.
Why connectivity cannot be decided without looking at every edgeTwo graphs on 6 vertices that differ in one edge. Any algorithm that has not examined that edge has seen exactly the same thing in both cases and must give the same answer, and the answers differ — the left graph is connected and the right is not. An adversary who watches which edges have been examined can always arrange for the undecided edge to be one of them, so every correct algorithm examines all E of them. This is a lower bound with nothing counted in it: it comes from what the algorithm has not seen.with the edge — connected012345all 6 edges presentwithout it — two components012345one edge withheld, everything else identicalV = 6, E = 6Ω(E), by adversary rather than by counting
Fig. 3 The smallest version of the construction. Six vertices, six edges, one withheld — and the argument is already complete, because it never depended on the size. A proof that works at V = 6 and V = 12 identically is a proof rather than an illustration.

What the algorithms actually spend

The floor says EE edge examinations. Breadth-first search on a connected graph of 2,048 vertices and 6,144 edges examines 12,288.

That is exactly 2E2E, and the factor of two is not slack in the algorithm. An undirected edge appears in two adjacency lists, and a traversal that walks every list walks each edge from both ends. Any implementation holding an undirected graph as adjacency lists pays this; the alternative is a representation that stores each edge once and cannot be scanned per-vertex, which nobody wants.

So the honest statement of the distance to the floor is: breadth-first search is at exactly twice the floor, and the factor of two is a property of the representation rather than of the algorithm. That is a much tighter relationship than the sorting field manages for anything except merge sort, and it is tight for a different reason: sorting’s algorithms approach their floor by being clever, and traversal reaches within a factor of two of its floor by having almost nothing to do.

It also means there is no research programme here. In sorting, merge sort at 1.02 says where not to look and the remaining 2% is provably unavailable. In connectivity, the remaining factor of two is available in principle — a CSR structure could scan each edge once given a direction convention — and it is not worth having, because the constant is two and the code becomes wrong for every algorithm that needs both directions.

Where the bound stops applying, which is the interesting part

An Ω(E)\Omega(E) bound on connectivity sounds final. Three quite ordinary situations get under it, and each gets under it by changing the question rather than by being clever — which is the pattern the floors field keeps finding.

If the graph is already in memory in a structure that answers the question. Maintain a union–find alongside the edge insertions, and connectivity is one comparison of two roots. The Ω(E)\Omega(E) has not been beaten; it has been paid in advance, one edge at a time, during construction. This is the same move as pre-sorting to make search logarithmic: the floor is on the total, and moving work earlier changes when it is spent rather than whether.

If a wrong answer is sometimes acceptable. An algorithm that samples kk edges and says “probably connected” is fast and is not solving the problem the bound is about. The adversary argument requires the algorithm to be correct on every input; a randomised algorithm allowed to err with small probability is playing a different game, and for several graph properties the randomised bound is genuinely lower than the deterministic one.

If the question is about a promise. “Decide whether this graph is connected, given that it is either connected or has at least ϵV2\epsilon V^2 edges missing” is a property-testing question, and it can be answered by looking at a constant number of vertices — independent of VV entirely. The adversary cannot construct its two graphs, because one of them would violate the promise.

All three are the same manoeuvre in different clothes: the bound is over a set of inputs and a standard of correctness, and shrinking either lowers the floor. A floor is a property of the question, and these are three different questions.

Why connectivity cannot be decided without looking at every edgeTwo graphs on 12 vertices that differ in one edge. Any algorithm that has not examined that edge has seen exactly the same thing in both cases and must give the same answer, and the answers differ — the left graph is connected and the right is not. An adversary who watches which edges have been examined can always arrange for the undecided edge to be one of them, so every correct algorithm examines all E of them. This is a lower bound with nothing counted in it: it comes from what the algorithm has not seen.with the edge — connected01234567891011all 12 edges presentwithout it — two components01234567891011one edge withheld, everything else identicalV = 12, E = 12Ω(E), by adversary rather than by counting
Fig. 4 The same construction on twelve vertices. The argument does not care about the size, which is the mark of a proof rather than an example — the adversary’s two graphs exist for any V and any set of examined edges short of all of them.

Two more sizes, and the point of drawing them is that nothing in the argument reads the size. The construction is a recipe, and the recipe produces a witness at every VV.

Why connectivity cannot be decided without looking at every edgeTwo graphs on 10 vertices that differ in one edge. Any algorithm that has not examined that edge has seen exactly the same thing in both cases and must give the same answer, and the answers differ — the left graph is connected and the right is not. An adversary who watches which edges have been examined can always arrange for the undecided edge to be one of them, so every correct algorithm examines all E of them. This is a lower bound with nothing counted in it: it comes from what the algorithm has not seen.with the edge — connected0123456789all 10 edges presentwithout it — two components0123456789one edge withheld, everything else identicalV = 10, E = 10Ω(E), by adversary rather than by counting
Fig. 5 Ten vertices, two graphs differing in one edge, the left connected and the right not. An algorithm that has not examined that edge has seen the same thing in both and must answer the same way for both, so it is wrong about one of them.
Why connectivity cannot be decided without looking at every edgeTwo graphs on 16 vertices that differ in one edge. Any algorithm that has not examined that edge has seen exactly the same thing in both cases and must give the same answer, and the answers differ — the left graph is connected and the right is not. An adversary who watches which edges have been examined can always arrange for the undecided edge to be one of them, so every correct algorithm examines all E of them. This is a lower bound with nothing counted in it: it comes from what the algorithm has not seen.with the edge — connected0123456789101112131415all 16 edges presentwithout it — two components0123456789101112131415one edge withheld, everything else identicalV = 16, E = 16Ω(E), by adversary rather than by counting
Fig. 6 And sixteen. The picture is the same picture, which is the whole content of the bound: an adversary who watches which edges have been examined can always leave the undecided one until last, so every correct algorithm examines all EE of them.

Evasiveness, and what is still open

The connectivity bound above is stated for adjacency lists, where the algorithm reads EE edge records. There is a sharper version for the adjacency-matrix model, where the algorithm probes pairs and there are (V2)\binom{V}{2} of them.

Connectivity in that model is evasive: every one of the (V2)\binom{V}{2} pairs must be probed in the worst case, not merely a constant fraction of them. The adversary strategy that proves it is more involved than the one above but the shape is identical.

Evasiveness is not a curiosity. The Aanderaa–Karp–Rosenberg conjecture says that every non-trivial monotone graph property is evasive — every property that cannot be destroyed by adding edges, and that is not constant, requires all (V2)\binom{V}{2} probes. It is known for prime VV by a topological argument of Kahn, Saks and Sturtevant, and it is open in general. That is worth stating in a field about floors, because it is a place where the floor is conjectured rather than known, and the site’s other floor is a two-line theorem from 1950s information theory.

The contrast is the useful part. Sorting’s floor is exact, provable in a paragraph, and matched to within 2%. Connectivity’s floor is provable in a paragraph in one model, matched to within a factor of two, and its sharpest form is a fifty-year-old open problem. Neither is typical, and having both stops the field from suggesting that lower bounds come in one flavour.

Two questions, two floors, n = 4096Sorting 4096 elements cannot be done in fewer than 43,250 comparisons; finding one element in a sorted array of 4096 cannot be done in fewer than 13, and binary search's worst case over all 4096 targets is exactly 13. The difference is a factor of 3,327, and it comes entirely from how many outcomes the algorithm must be able to distinguish — 4096! orderings against 4096 + 1 positions. A lower bound is a property of the question, not of any algorithm.comparisons (bar length is log-scaled)sorting, floor43,250sorting, merge sort43,976searching, floor13searching, binary13searching, linear4,096green outline: a proved floor · blue: a measured run3,327× between the two floors
Fig. 7 Four questions about the same data, with the floor under each. Sorting, searching a sorted array, searching an unsorted one, and finding a minimum. Every bar is a different question and the bars are nothing like each other — which is the general form of what the connectivity bound is an instance of.

The sorting bound, recast

The two techniques look like different subjects, and they are not: the sorting bound can be proved by an adversary too, and seeing it done makes the relationship between them clear.

The adversary holds a set of permutations consistent with every answer it has given so far. It starts with all n!n! of them. When the algorithm asks whether ai<aja_i < a_j, the adversary answers in whichever direction leaves more permutations alive — and since every permutation is in one camp or the other, one of the two directions leaves at least half.

So after kk comparisons at least n!/2kn!/2^k permutations remain consistent. The algorithm cannot stop while two remain, because two consistent permutations mean two different correct outputs and it must produce one of them. Therefore n!/2k<2n!/2^k < 2, giving k>log2(n!)1k > \log_2(n!) - 1.

That is the same bound, from the same starting point, argued the other way round. The decision-tree version counts leaves and bounds the depth; the adversary version keeps the candidate set large and bounds the number of halvings. They are dual statements about one quantity.

What the recasting shows is where the two techniques actually differ, and it is not the mathematics. It is what the adversary is allowed to withhold.

In sorting, the adversary withholds the ordering and the algorithm’s questions each remove at most half the possibilities. The set shrinks geometrically, so a logarithmic number of questions suffices and the bound is logarithmic.

In connectivity, the adversary withholds one edge and the algorithm’s questions remove nothing until it asks about that specific edge. The set does not shrink geometrically; it stays ambiguous until the last unexamined input is examined, and the bound is linear in the number of inputs.

Geometric shrinkage gives a logarithm; no shrinkage at all gives coverage. Every lower bound of either kind is somewhere between those two, and knowing which end a problem is near is the first thing to establish about it.

What the adversary cannot do

An adversary argument bounds deterministic algorithms, and stating why is worth a section because the gap is where a great deal of modern algorithm design lives.

The argument’s move is: the algorithm’s next question is determined by the answers so far, so the adversary knows it in advance and can prepare. Against a randomised algorithm that step fails. The adversary does not know which question is coming, so it cannot arrange for the undetermined input to be the one that is skipped — it can only make that likely, and “likely” is not what a correctness proof needs.

The consequence is not that randomisation beats every lower bound. For connectivity it does not: reading every edge is still required, because a randomised algorithm that skips edges gets the answer wrong with positive probability on some input, and an algorithm allowed to be wrong is solving a different problem. What changes is that the technique stops applying, and a separate argument is needed.

The standard replacement is Yao’s principle, and its shape is elegant enough to state. To lower-bound a randomised algorithm’s expected cost on the worst input, choose a distribution over inputs and lower-bound the expected cost of the best deterministic algorithm on that distribution. The two are related by a minimax argument, and the second is a question about deterministic algorithms again — which is to say, the technique for bounding randomised algorithms is to find the right distribution and then use the deterministic techniques.

That is worth knowing here because it explains a pattern in this site’s other field. Randomising a pivot defeats an adversary who chooses the input, and it does not lower the expected cost by a single comparison — randomised quicksort’s mean at n=512n = 512 is 4,946 against the first-element rule’s 4,935 on random input. Randomisation moved the guarantee from “fast if the data is nice” to “fast unless the coin flips go badly”, and bought nothing in expectation. The adversary framing is exactly what makes that trade legible: what was purchased is immunity to an opponent, not speed.

Two floors that are not adversary arguments

Worth a short note, because the pattern of “one technique per field” is what this essay is arguing against and two more techniques are close by.

Reduction. Most lower bounds in practice are neither counting nor adversary arguments; they are reductions. Show that solving problem A quickly would solve problem B quickly, and inherit B’s bound. The sorting bound propagates this way to element uniqueness, to convex hull, and to a great deal else, and none of those results is proved directly.

Communication. For a bound on a distributed or streaming computation, the argument is usually that some quantity of information must cross a boundary. That is neither a count of outputs nor an adversary withholding an input; it is a count of bits on a wire, and it is the technique behind most streaming lower bounds.

Neither is measurable at this site’s scale and both belong in a list of what a lower bound can be, because the field’s two examples — one counting, one adversary — do not span the subject and this essay would be misleading if it left the impression that they did.

The certificate is a sixth of the floor

There is a gap between the bound and the answer that the adversary argument makes vivid and does not name, and it is worth a section because it is where most of algorithm design actually happens.

The bound is on finding the answer. It is not a bound on checking one, and for connectivity the two are wildly apart in both directions.

A spanning tree certifies connectivity. Hand somebody V1V-1 edges and they can verify in V1V-1 steps that these edges join every vertex — no reference to the rest of the graph at all. On the measured graph that is 2,047 edges, against the 12,288 list entries breadth-first search reads to produce it. The certificate is a sixth of what it costs to find.

And a closed set certifies disconnection. Hand somebody a set SS of vertices and the claim that no edge leaves it, and they check by reading SS’s adjacency lists and nothing else — which for a small component is a handful of entries out of six thousand.

So both answers have certificates far below Ω(E)\Omega(E), and the floor is untouched by that, because a certificate has to be found before it can be checked. That is the ordinary state of affairs and it is easy to lose sight of when a bound is quoted as though it were about the problem rather than about the search.

The disconnection certificate has a second consequence the page states for the matrix model and not for lists: the Ω(E)\Omega(E) is worst-case, and the best case is a constant. Breadth-first search from a vertex in a small component reads that component’s lists, finds it reaches fewer than VV vertices, and answers — having examined none of the edges among the other two thousand. It is correct, because reaching fewer than every vertex proves disconnection whatever the unread edges say.

So the adversary’s construction is not describing every input; it is describing the hard ones, and the hard ones are the connected graphs and the graphs that are one edge from connected. Every graph comfortably far from the boundary is cheap. That is the same structure as the floor moves when the question does’s argument, arriving inside one question rather than between four: the floor is over a set of inputs, and most members of the set are nowhere near it.

Which puts the factor of two in its place. Breadth-first search is at 2E2E on a connected graph, at the floor’s constant on the worst input, and at essentially nothing on a graph that falls apart early — so twice the floor is the price of the worst case and not the price of a run. How close anything gets to the floor reports sorting’s distance as a single ratio because sorting’s cost barely moves across inputs; connectivity’s ratio needs an input named beside it, and the range is the whole graph.

The adversary as a way of thinking

The technique generalises past lower bounds, and it is worth naming the generalisation because it is what makes the argument feel like a tool rather than a trick.

An adversary argument is: assume the input is not fixed until it has to be. The opponent is not withholding information out of malice, it is refusing to commit, and it commits at the last possible moment in whichever way hurts most.

That is the same posture behind several things already on this site. Randomising a pivot is a defence against exactly this opponent, and it works by making the algorithm’s choices unavailable to it. The lower bound on comparison sorting can be recast in adversary form — answer each comparison in whichever direction leaves more permutations alive, and the algorithm needs log2(n!)\log_2(n!) questions to get the survivor count down to one — and the recast version is the same theorem with a different proof.

What the adversary framing adds, in every case, is a way to ask what has this algorithm not yet ruled out. That question is answerable when “how many bits has it acquired” is not.

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

The 8 essays that link to this one and share the most of its objects, of 17 that link here.

The objects this essay names

Each one links to every other essay that touches it.

AdjacencyAdjacency listAdversary argumentConnectivityDecision treeDistributionEvasivenessLower boundRandomised algorithmTraversal