|q⟩ Bad Qubits

advanced · Physics · Quantum Complexity Theory

Checkpoint: Query Complexity

This checkpoint consolidates the module's query-complexity thread by putting four canonical black-box problems side by side and computing, for each, the quantum and classical query counts. The point is to read off the shape of the speedup — quadratic, exponential, or none — and to see why structure in the oracle is what determines it.

The four problems

| Problem | Promise / task | Quantum queries | Classical (worst case) | Speedup | |---|---|---|---|---| | Deutsch–Jozsa | ff constant or balanced; decide which | 11 | N/2+1N/2 + 1 | exponential | | Bernstein–Vazirani | f(x)=axmod2f(x) = a\cdot x \bmod 2; find aa | 11 | nn | linear \to constant | | Simon | f(x)=f(xs)f(x)=f(x\oplus s); find period ss | O(n)O(n) | Θ(N)\Theta(\sqrt N) | exponential | | Grover | one marked item; find it | Θ(N)\Theta(\sqrt N) | Θ(N)\Theta(N) | quadratic |

For the exercise we fix n=6n = 6, so N=2n=64N = 2^n = 64.

Where each number comes from

Deutsch–Jozsa. A single query to the phase oracle, sandwiched by Hadamards, maps the all-zeros input to a state that is 00\ket{0\cdots0} iff ff is constant. One quantum query decides it exactly. Classically, a deterministic algorithm could see up to N/2N/2 equal values and still not know (a balanced function could agree on the first half); it needs N/2+1N/2 + 1 queries in the worst case to be certain — 3333 for N=64N=64. This is the first exponential separation, albeit only for exact (zero-error) computation; with randomness the classical gap shrinks.

Bernstein–Vazirani. Here the same one-query Hadamard sandwich returns the entire hidden string aa at once: the final measurement yields aa with certainty. Classically each query f(ei)=aif(e_i) = a_i reveals a single bit, so nn queries are needed and sufficient. The separation is nn versus 11 — modest, but a clean illustration of extracting global information in one shot.

Simon. The exponential speedup that directly inspired Shor. Each quantum query yields a random vector yy orthogonal to the hidden period ss; after O(n)O(n) queries one has n1n-1 independent constraints and solves a linear system over F2\mathbb F_2 for ss. Classically, finding a collision f(x)=f(x)f(x)=f(x') requires probing Θ(N)=2n/2\Theta(\sqrt N) = 2^{n/2} inputs by the birthday bound — 88 queries for n=6n=6 — and this is a proven lower bound, making Simon an unconditional exponential separation in the query model.

Grover. As derived earlier, θ=arcsin(1/N)\theta = \arcsin(1/\sqrt N) and the optimal iteration count is round ⁣(π/(4θ)1/2)\mathrm{round}\!\big(\pi/(4\theta) - 1/2\big), which for N=64N=64 is 66 (close to π4646.28\tfrac{\pi}{4}\sqrt{64} \approx 6.28). Classically a deterministic search needs N1=63N-1 = 63 queries in the worst case. The ratio 6363 vs 66 reflects the Θ(N)\Theta(N) vs Θ(N)\Theta(\sqrt N) quadratic gap.

Try it

Fix n=6n=6 (N=64N=64) and compute, from first principles, the quantum and classical query counts for all four problems, plus two booleans: whether Grover's speedup is quadratic (classical \approx quantum2^2) and whether Simon's is exponential. return the object { N, groverQ, groverC, djQ, djC, bvQ, bvC, simonQ, simonC, groverSpeedupIsQuadratic, simonSpeedupIsExponential }.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.