Self-Assessment Quiz: Deutsch-Jozsa and Bernstein-Vazirani

Twenty questions on the first quantum algorithms, oracle models, promise problems, and how seriously to take their speedups. Aim for 16+.


Question 1

Deutsch–Jozsa decides whether $f:\{0,1\}^n\to\{0,1\}$ is:

A) Injective or surjective B) Constant or balanced, given a promise that it is one of the two C) Linear or nonlinear D) Computable

Question 2

Classically, deciding this with certainty requires in the worst case:

A) 1 query B) $n$ queries C) $2^{n-1}+1$ queries D) $2^n$ queries

Question 3

Deutsch–Jozsa requires:

A) 1 query B) $n$ queries C) $\sqrt{2^n}$ queries D) $2^n$ queries

Question 4

Classically, with a randomized algorithm accepting small error probability, you need:

A) $2^{n-1}+1$ queries B) $O(1)$ queries C) $O(n)$ queries D) $O(2^n)$

Question 5

That last fact means the Deutsch–Jozsa speedup is:

A) Exponential over any classical method B) Exponential only over deterministic classical algorithms C) Nonexistent D) Quadratic

Question 6

The final measurement in Deutsch–Jozsa gives all zeros iff:

A) $f$ is balanced B) $f$ is constant C) $f$ is linear D) Always

Question 7

Bernstein–Vazirani finds the hidden string $s$ in $f(x) = s\cdot x \bmod 2$ using:

A) 1 query B) $n$ queries C) $2^n$ queries D) $\log n$ queries

Question 8

Classically, finding $s$ requires:

A) 1 query B) $n$ queries C) $2^n$ queries D) $n^2$ queries

Question 9

So Bernstein–Vazirani's speedup is:

A) Exponential B) Linear ($n\to1$) C) Quadratic D) None

Question 10

The state after the oracle in Bernstein–Vazirani is:

A) $\frac{1}{\sqrt{2^n}}\sum_x(-1)^{s\cdot x}|x\rangle$ B) $|s\rangle$ C) Uniform with no phases D) Entangled with the ancilla

Question 11

Applying $H^{\otimes n}$ to that state yields:

A) Uniform superposition B) $|s\rangle$ exactly C) $|0\rangle$ D) A random state

Question 12

The oracle in these algorithms is:

A) A physical device you buy B) A black box counted per query — the resource being measured C) Always free D) Classical only

Question 13

A "promise problem" is one where:

A) Any input is allowed B) Inputs are guaranteed to satisfy a condition, and behavior is unconstrained otherwise C) The answer is probabilistic D) The oracle may lie

Question 14

Deutsch–Jozsa's practical importance is mainly:

A) Direct application to real problems B) Historical and conceptual — the first provable exponential separation in the query model C) Cryptanalysis D) Chemistry simulation

Question 15

Building the oracle circuit for a given $f$ typically costs:

A) Nothing B) Gates that may exceed the query savings C) Exactly one gate D) $2^n$ measurements

Question 16

True or false: Deutsch–Jozsa proves quantum computers beat classical ones on practical problems.

Question 17

True or false: Bernstein–Vazirani's output is deterministic on a noiseless device.

Question 18

True or false: These algorithms need entanglement between the input qubits.

Question 19

Short answer. Explain why the query-model speedup can be misleading when the oracle must be built from gates.

Question 20

Short answer. Why is Bernstein–Vazirani a good hardware benchmark despite being a modest speedup?


Answer Key

Q Ans Note
1 B The promise is essential — without it the problem is different and the algorithm's guarantee does not apply.
2 C You must check just over half the inputs: $2^{n-1}$ agreeing values still leaves both cases open.
3 A One oracle query, with certainty.
4 B A handful of random samples distinguishes constant from balanced with overwhelming probability — a few queries suffice for any fixed error.
5 B This is the honest framing, and it is frequently omitted. Against randomized classical algorithms the separation collapses.
6 B Constant $f$ gives amplitude $\pm1$ on all zeros; balanced gives exactly 0.
7 A One query.
8 B Query $e_i$ for each basis vector to read one bit of $s$ at a time.
9 B $n$ queries to 1 — real and provable, including against randomized classical algorithms, but linear rather than exponential.
10 A Phase kickback writes $s\cdot x$ into the sign.
11 B That state is the Hadamard transform of $|s\rangle$, and $H$ is its own inverse.
12 B The query model measures oracle calls, deliberately ignoring the cost of implementing the oracle.
13 B Behavior on promise-violating inputs is undefined — which is why these results do not translate directly into general-purpose algorithms.
14 B Nobody needs to know whether a function is constant or balanced. Its value is as the first proof that quantum query complexity can be exponentially smaller.
15 B Constructing $U_f$ for a specific $f$ can require many gates — the saved queries may cost more than they save.
16 False It is a promise problem in an artificial oracle model, with the separation holding only against deterministic classical algorithms.
17 True The output is exactly $|s\rangle$ with probability 1 in the noiseless case.
18 False Both algorithms work on product states throughout the input register; the oracle may entangle input and ancilla transiently, but no entanglement between input qubits is required. This is a useful reminder that entanglement is not the sole source of quantum advantage (Ch. 6).
19 The query model charges one unit per oracle call and nothing for constructing the oracle. In practice $U_f$ must be compiled into gates, and for a complicated $f$ that circuit can be enormous — potentially exponential. An algorithm saving exponentially many queries while requiring an exponentially large oracle circuit has saved nothing. Query complexity is a lower-bound tool and a poor cost model for end-to-end applications.
20 Its output is a single deterministic bitstring on an ideal device, so any deviation is directly attributable to hardware error — no statistical inference is needed to interpret the result. It scales to any qubit count, its circuit depth is shallow and constant in $n$, and success probability degrades smoothly with error rate. That makes it an excellent, cheap system-level check, which is why it appears in vendor benchmark suites far more often than its algorithmic importance would justify.