Part V · Chapter 22

Quantum Parallelism

Read ~18 min Prerequisites Ch. 3, Ch. 5, Ch. 7 Tools live truth-table widget, code cell Live
Basic

Every algorithm in Part V is some clever variation on a single trick: put n qubits into superposition with H gates, query a function once, and the result somehow encodes information about every possible input at once. This chapter is purely about that trick — quantum parallelism itself — before the next nine chapters show what you can actually do with it.

The setup

Start with n qubits at |0...0⟩, apply H to every one of them. Ch. 1's linear-combination idea, scaled up: the result is an equal superposition of all 2ⁿ possible n-bit strings.

H^⊗n |0...0⟩ = (1/√N) Σₓ |x⟩, N = 2ⁿ

Now query an oracle — a black box implementing some function f — once. Because the oracle acts linearly on a superposition (Ch. 4: every quantum gate is linear), it touches every term in that sum simultaneously. One query; every value of f, all encoded into the resulting amplitudes at once.

Fig. 22.1 — the universal opening moveevery algorithm in Part V starts here
q0: |0⟩ q1: |0⟩ ... qn: |0⟩ H H H Uf
H-layer, then one oracle query. What you do after this — Ch. 25 onward — is the entire content of quantum algorithms. This opening is always the same.
Intermediate
Fig. 22.2 — define f, watch every value get encodedn=2, click a cell to flip f(x)

Click any f(x) value to flip it and watch the amplitude pattern change instantly — every change to the truth table is reflected after just one (simulated) oracle call.

The catch — and why it matters

Here's the sentence that separates a real understanding of this topic from a popular-science one: quantum parallelism on its own gives you nothing useful. Measure the state in Fig. 22.2 right now and you get one random x with its one value of f(x) — exactly what a classical random guess would give you. All that rich, simultaneously-computed information is sitting in the amplitudes, but Ch. 7's Born rule only ever lets you read out one outcome, and it destroys the rest.

Advanced

What actually makes an algorithm work

Every algorithm from Ch. 25 onward is, underneath the specific problem it solves, an exercise in designing the second half of the circuit — what happens after the oracle — so that interference concentrates probability onto one specific, useful measurement outcome instead of leaving it spread uniformly across all 2ⁿ possibilities. Quantum parallelism supplies the raw material (every value of f, computed at once); a second layer of carefully chosen gates is what turns that raw material into an actual speedup. Ch. 26's Deutsch–Jozsa algorithm is the simplest possible example of this two-step pattern, and you already have every piece you need to understand exactly how it works.

Fig. 22.3 — code, runs in your browser
Same computation Fig. 22.2 runs live — confirms there's no hidden trick in the visualization.
Check your understanding

What does H^⊗n |0...0⟩ produce, and why does that let an oracle query "touch" every input at once?

An equal superposition of all 2ⁿ n-bit strings. Because the oracle acts linearly, querying it once is equivalent to applying it to every term in that superposition simultaneously.

Check your understanding

If you measure the state in Fig. 22.2 right after the oracle, what do you get?

One random x, with no more information than a classical random guess would give you — quantum parallelism alone provides no advantage.

Check your understanding

What's actually needed to turn quantum parallelism into a real speedup?

A carefully designed second stage of gates, applied after the oracle, that uses interference to concentrate the measurement probability onto one specific, useful outcome — rather than leaving it spread evenly across all possibilities.

Check your understanding

For n=3 qubits, how many input values does a single oracle query touch under quantum parallelism?

2³ = 8 — every possible 3-bit string, all in one query.

Check your understanding

Why is "quantum computers try every answer at once" a misleading way to describe parallelism?

Because trying every answer "at once" only encodes information in amplitudes you can't directly read out — without a second, carefully designed stage exploiting interference, you can only ever measure one random answer, exactly like a classical guess.

Review queue

Scroll back to a chapter's quiz cards to review them once they're due — a full cross-chapter queue view is a planned upgrade.