Level 7 · Capstone Topics
Practice Set 2: Quantum Algorithms with Worked Solutions
About 5,060 words · roughly 23 minute read · sources checked December 3, 2026
The second practice set covers the algorithm lessons. Each problem hides its solution until you open it. The numbers in the solutions were computed with NumPy and standard Python, and the sets of results that overlap with other lessons on this site (phase estimation, VQE, QAOA) match the tables there.
These problems are for self-study. Where a result depends on a textbook formula that I did not open a source for, the solution says so.
What you will learn
- Compute Grover success probabilities and iteration counts.
- Run Deutsch–Jozsa and Bernstein–Vazirani by counting queries.
- Read the output of the QFT and of phase estimation.
- Factor small numbers by finding an order.
- Evaluate VQE energies, parameter-shift gradients and shot costs.
Helpful first: Grover’s Algorithm, Quantum Phase Estimation.
Grover’s algorithm
Each problem has a hidden answer. Click the question to open the worked solution. All numbers were computed in code.
Check yourself
A1. Grover search on N = 8 items with one marked item. What is the success probability after 0, 1, 2, 3 and 4 iterations? Which count is best?
With θ = arcsin(1/√N), the success probability after k iterations is sin²((2k+1)θ). For N = 8: k=0: 0.125, k=1: 0.7812, k=2: 0.9453, k=3: 0.3301, k=4: 0.0122. The best is k = 2, with 0.9453. After k = 3 the probability falls to 0.3301: running too long overshoots the target. Classical search needs about 4 checks on average and 8 in the worst case.
A2. For N = 1,048,576 (2²⁰) items with one marked, roughly how many Grover iterations are needed? How many checks does a classical search need on average?
About (π/4)√N = (π/4) × 1024 = 804.2, so about 804 iterations. A classical search checks N/2 = 524,288 items on average. The ratio is 652 to 1 in queries. Each Grover iteration is a more complex operation than one classical check, so this is a comparison of queries, not of running time.
A3. With M = 4 marked items among N = 1,024, how does the optimal iteration count change?
The count is about (π/4)√(N/M) = (π/4) × √256 = (π/4) × 16 = 12.6, so about 13 iterations, compared with 25.1 (about 25) for a single marked item. More marked items means fewer iterations. I derived this from the standard formula, which I did not re-open a source for here.
Deutsch–Jozsa and Bernstein–Vazirani
Check yourself
B1. A function takes 3 bits and is promised to be constant or balanced. How many queries does a deterministic classical algorithm need in the worst case? How many does Deutsch–Jozsa need?
There are 2³ = 8 inputs. A balanced function returns 0 on half of them, so after 4 identical answers you still cannot be certain; the worst case needs 2ⁿ⁻¹ + 1 = 5 queries. Deutsch–Jozsa needs 1 query. For n = 10 the classical worst case is 513 queries and the quantum count is still 1.
B2. Bernstein–Vazirani: the hidden string is s = 101 and the oracle computes s·x mod 2. How many queries does the classical and the quantum method need, and what does the quantum circuit output?
Classically you query the three unit strings 100, 010, 001 and read one bit of s from each: 3 queries. The quantum circuit uses 1 query and outputs the bit string 101 with probability 1. I simulated it: H on all qubits, the phase oracle (−1)^(s·x), then H again.
Fourier transform and phase estimation
Check yourself
C1. Write the QFT of |1⟩ on 3 qubits (N = 8).
QFT|1⟩ = (1/√8) Σₖ e^(2πi·k/8)|k⟩. Every amplitude has size 1/√8 = 0.3536, so all eight outcomes are equally likely, and only the phases differ. The phases in turns are 0, 1/8, 2/8, …, 7/8. Measuring right after the QFT would reveal nothing, which is why the QFT is used inside algorithms and not alone.
C2. In phase estimation with 3 counting qubits, the eigenphase is φ = 3/8. What does the circuit output, and with what probability?
3/8 = 0.011 in binary, which equals 3/2³ exactly, so the circuit outputs 011 with probability 1. My full circuit simulation confirmed this. The T gate (φ = 1/8) similarly gives 001.
C3. For φ = 0.3 and 4 counting qubits, which outcome is most likely, and how likely is it?
2⁴ × 0.3 = 4.8, so the nearest integers are 4 and 5. In my simulation the most likely outcome is 0101 (that is 5, reading 5/16 = 0.3125) with probability 0.8756. The estimate 0.3125 is off by 0.0125, less than half of one bin width 1/16 = 0.0625.
Shor’s algorithm
Check yourself
D1. Use the order r of a = 7 modulo N = 15 to find the factors of 15.
Compute powers of 7 mod 15 until you reach 1. The order is r = 4. Since r is even, take y = 7^(r/2) mod 15 = 4. Then gcd(y − 1, 15) = gcd(3, 15) = 3, and gcd(y + 1, 15) = gcd(5, 15) = 5. So 15 = 3 × 5.
D2. Use the order r of a = 2 modulo N = 21 to find the factors of 21.
Compute powers of 2 mod 21 until you reach 1. The order is r = 6. Since r is even, take y = 2^(r/2) mod 21 = 8. Then gcd(y − 1, 21) = gcd(7, 21) = 7, and gcd(y + 1, 21) = gcd(9, 21) = 3. So 21 = 7 × 3.
D3. For a = 4 and N = 15, find the order. Does the method give factors?
The order of 4 mod 15 is r = 2. Then y = 4^1 mod 15 = 4, and gcd(3, 15) = 3 and gcd(5, 15) = 5. So 15 = 3 × 5. It works here even though r is small.
D4. Phase estimation on a = 2, N = 21 (order 6) with t = 5 counting qubits fails to resolve the order. Why?
The eigenphases are multiples of 1/6, which are not powers-of-two fractions. With only 32 bins, neighbouring peaks overlap. In my simulation, 5 counting qubits gave no useful probability of recovering 6, and 8 counting qubits gave the exact order directly in 28.5% of runs. Textbooks recommend about 2·log₂N counting qubits, which is the rule I stated in the phase-estimation lesson without an opened source.
VQE and QAOA
Check yourself
E1. For H = Z + 0.5X and the ansatz Ry(θ)|0⟩, E(θ) = cos θ + 0.5 sin θ. Compute E at θ = 0, 2 and 3.6052, and say what the minimum is.
E(0) = 1, E(2) = 0.0385, and E(3.6052) = -1.11803. The exact minimum is −√(1 + 0.25) = -1.118034, reached at θ = π + arctan(0.5) = 3.6052.
E2. Use the parameter-shift rule to find dE/dθ at θ = 1.0.
dE/dθ = [E(θ + π/2) − E(θ − π/2)] / 2. Here E(1 + π/2) = -0.57132 and E(1 − π/2) = 0.57132, so the slope is -0.57132. The analytic derivative −sin(1) + 0.5 cos(1) = -0.57132 agrees.
E3. A VQE energy estimate has variance 0.27. How many shots does it take to reach a standard error of 0.01? How many for 0.001?
Standard error = √(variance/S), so S = variance / error². For 0.01: 0.27 / 0.0001 = 2700 shots. For 0.001: 0.27 / 0.000001 = 270,000 shots. Ten times more precision costs a hundred times more shots.
E4. A triangle graph has best Max-Cut value 2. What is the average cut of a uniformly random assignment, and what ratio does that give?
Each of the 3 edges is cut with probability ½, so the average is 1.5, and the ratio is 1.5 / 2 = 0.75. In my QAOA simulation, a triangle reaches an average of 2.0 (ratio 1.0) already at depth p = 1.
More Grover problems: tuning, overshoot and many marked items
The first Grover problems used a single formula. These ones make you use it the way a practitioner does: choose the iteration count, notice what changes when several items are marked, and see why running too long is a mistake. Every number below comes from sin²((2k+1)θ) with θ = arcsin(√(M/N)), evaluated in Python.
Check yourself
F1. N = 16 with one marked item. List the success probability after k = 0, 1, 2, 3, 4 and 5 iterations. Which k would you choose?
Using θ = arcsin(1/4) = 0.2527 rad: k=0: 0.0625, k=1: 0.4727, k=2: 0.9084, k=3: 0.9613, k=4: 0.5817, k=5: 0.1255. Choose k = 3, with success probability 0.9613. Notice that k = 4 is already much worse than k = 3. The state keeps rotating, so more iterations are not better. The rotation per iteration is 2θ ≈ 0.505 rad (about 29°), and the target sits at 90° from the start, so about 3.1 iterations get you there.
F2. N = 64 with M = 4 marked items. Compute the best k and its success probability. Compare with F1.
Here θ = arcsin(√(4/64)) = arcsin(1/4), which is exactly the same angle as in F1. So the probabilities are identical: k = 3 gives 0.9613. The lesson is that only the ratio M/N matters. Searching for 4 items among 64 behaves like searching for 1 item among 16. This is why a search with many solutions is faster, and why the iteration count scales like √(N/M).
F3. N = 4 with one marked item. What happens at k = 1 and at k = 2?
θ = arcsin(1/2) = 30°. At k = 1 the angle is 3θ = 90°, so P = sin²(90°) = 1.0000: a single iteration finds the item with certainty. At k = 2 the angle is 5θ = 150°, so P = sin²(150°) = 0.25, which is no better than guessing. This is the smallest case where Grover is exact, and it is the circuit in the two-qubit widget below.
F4. N = 256 with one marked item. Give the best k and P(best), and P at k = 13 and k = 14.
θ = arcsin(1/16) = 0.06254 rad. The best k is 12, with P = 0.9999. At k = 13, P = 0.9862, and at k = 14, P = 0.9422. The curve is flat near the top, so being off by one iteration costs little, but being off by a large amount does. Compare with F1, where the top is narrower.
F5. A database has N = 2⁴⁰ items and one marked item. How many Grover iterations are needed? Why is that not a practical speed-up today?
(π/4)√N = (π/4) × 2²⁰ = 823,550 iterations, rounded to the nearest integer. A classical search needs about 2³⁹ ≈ 5.5 × 10¹¹ checks on average. The ratio looks enormous, but each Grover iteration must evaluate the oracle on a superposition of 2⁴⁰ items inside an error-corrected circuit. If one iteration takes a millisecond of logical time, 823,550 iterations take about 14 minutes, which sounds fine. The catch is the oracle: it must be a reversible circuit for the check, and if the 'database' is just a list in memory, loading it into a quantum state is itself a classical cost of 2⁴⁰ operations. Grover helps for problems where the check is computed, such as a cryptographic key test, and not for lookup in stored data.
More query-counting problems: Deutsch–Jozsa and Bernstein–Vazirani
Query counting is a fair comparison because it measures the one thing the quantum algorithm saves. These problems extend B1 and B2 to larger sizes. Keep in mind that the speed-up applies to a promise problem. Without the promise there is no saving.
Check yourself
G1. A function on n = 10 bits is promised constant or balanced. What is the worst-case number of queries for a deterministic classical algorithm? How many does Deutsch–Jozsa use?
Out of 2¹⁰ = 1,024 inputs, a balanced function returns 0 on 512. In the worst case the first 512 queries all return the same value and you cannot yet tell the cases apart. The 513th query settles it. So the worst case is 2⁹ + 1 = 513 queries. Deutsch–Jozsa uses exactly 1 query to the oracle, followed by one Hadamard layer and a measurement. If the result is all zeros the function is constant, otherwise it is balanced.
G2. A randomised classical algorithm for the same problem stops after k queries and answers 'constant' if all results agree. For a balanced function, roughly what is the chance of being wrong after k = 5 and k = 10 queries?
For a balanced function, the chance that k random queries all return the same value is about 2 × (1/2)ᵏ, or 2^(1−k). For k = 5 that is 2⁻⁴ = 0.0625 and for k = 10 it is 2⁻⁹ ≈ 0.00195. (This is a standard approximation for sampling with replacement. I computed it from the formula and did not simulate it.) The lesson is that a randomised classical algorithm closes most of the gap: with 10 queries, a 0.2% error is acceptable for most uses. That is why the Deutsch–Jozsa advantage is mostly a conceptual result about exactness, not a practical one.
G3. Bernstein–Vazirani with a hidden string of n = 20 bits. How many queries does each side need?
Classically, you query the 20 basis inputs 100…0, 010…0 and so on. Each answer gives one bit of s, so 20 queries are needed and cannot be reduced, because each query returns one bit of information. The quantum algorithm uses 1 query and recovers all 20 bits at once, because the Hadamard layers turn the phases (−1)^(s·x) into the bits of s. The saving is a factor of n, which is a polynomial speed-up. The caveat from G2 applies: the problem is artificial, but the circuit is a clean teaching example of interference.
G4. In the Bernstein–Vazirani circuit, the hidden string is s = 110 on three qubits. Which CNOT gates does the oracle contain, and what does the final measurement show?
The oracle computes s·x mod 2 = x₀ ⊕ x₁ (counting bits from the left of the string 110). So it contains one CNOT from each qubit where s has a 1 onto the ancilla, which is two CNOT gates and none from the third qubit. After the final Hadamard layer, the data qubits are measured as 110 with probability 1. You can confirm this in the Bernstein–Vazirani widget on the circuit-run section below.
More phase estimation and Fourier problems
Phase estimation is the algorithm where reading a distribution carefully matters most. The problems below ask for probabilities, counts of gates and resolution. The exact probabilities were computed from the standard amplitude formula for the counting register and match the numbers in the phase-estimation lesson.
Check yourself
H1. Phase estimation with t = 3 counting qubits on an eigenphase φ = 1/3. Give the probabilities of the three most likely outputs.
The register can only hold multiples of 1/8. The nearest is 3/8 = 0.375, and the output 011 appears with probability 0.6878. The next two are 010 (2/8 = 0.25) with 0.1749 and 100 (4/8 = 0.5) with 0.0469. The probability of landing on 010, 011 or 100 together is 0.9097. In the first widget below the same circuit is run on the browser simulator, and the counts should match these numbers within sampling noise.
H2. How does the probability of the best outcome change as t grows, for φ = 1/3?
Computed: t = 3 gives 0.6878, t = 4 gives 0.6849, t = 5 gives 0.6842, t = 6 gives 0.6840. The probability of the single best outcome settles near 0.684 and does not rise toward 1, because 1/3 is not a binary fraction. What improves is the precision: the best outcome is the closest t-bit fraction to φ, so the error shrinks like 2⁻ᵗ. The probability of being within one step of the best outcome stays about 0.90, again from computation.
H3. You want to estimate a phase to within ±0.001. How many counting qubits are needed at minimum?
The step size is 2⁻ᵗ and the error of the best outcome is at most 2⁻ᵗ⁻¹. Requiring 2⁻ᵗ⁻¹ ≤ 0.001 gives t ≥ 9, since 2⁻¹⁰ = 0.000977. With t = 9 the controlled-U is applied up to 2⁹ − 1 = 511 times in the largest controlled block. To keep the probability of a bad outcome low, a few extra counting qubits are normally added; the usual formula for how many comes from a textbook that I did not open here.
H4. How many gates does the QFT on n = 10 qubits need, counting Hadamards and controlled phase rotations?
The standard circuit uses n Hadamards and n(n−1)/2 controlled phase rotations, plus about n/2 swaps at the end. For n = 10 that is 10 Hadamards and 45 controlled rotations, so 55 gates before the 5 swaps. The count grows like n², which is the polynomial cost that makes the QFT cheap compared with the classical FFT on 2ⁿ points. The smallest rotations have angles of 2π/2¹⁰, and these tiny angles can often be dropped, as the approximate-QFT lesson shows.
H5. The QFT of |0⟩ on 3 qubits: what are the amplitudes? What about |4⟩?
For |0⟩, the output is the uniform superposition with every amplitude 1/√8 = 0.3536 and all phases equal to zero. For |4⟩ the magnitudes are the same, but the amplitude on basis state j carries the phase e^(2πi·4j/8) = (−1)ʲ, so the sign alternates between neighbours. The magnitudes cannot distinguish the inputs. Only the phases carry the information, which is why phase estimation applies the inverse QFT and why a measurement straight after a forward QFT is uninformative.
More order-finding problems
Shor's algorithm has a quantum part (finding the order r) and a classical part (turning r into factors). The classical part is where many learners lose points, because it has conditions that can fail. These problems exercise it. The orders were computed by brute force in Python.
Check yourself
I1. Factor N = 35 using a = 2. Find the order and the factors.
Compute the powers of 2 modulo 35: 2, 4, 8, 16, 32, 29, 23, 11, 22, 9, 18, 1. So the order is r = 12. It is even, so compute a^(r/2) = 2⁶ = 64 ≡ 29 (mod 35). This is not −1 (which would be 34), so the method works. gcd(29 − 1, 35) = gcd(28, 35) = 7 and gcd(29 + 1, 35) = gcd(30, 35) = 5. So 35 = 7 × 5.
I2. For N = 15, which values of a coprime to 15 give a usable order? What fraction is that?
The values coprime to 15 between 2 and 14 are 2, 4, 7, 8, 11, 13 and 14, which is 7 values. Their orders are 4, 2, 4, 4, 2, 4 and 2. Of these, 6 give an even order with a^(r/2) not equal to −1 mod 15. The failing one is a = 14, since 14 ≡ −1 and r = 2, so a^(r/2) = 14 ≡ −1. So 6 of 7, about 86%, work. For N = 21 only 6 of 11 coprime values work (about 55%), and for N = 35, 18 of 23 (about 78%). The numbers are small samples, but they show why Shor's algorithm is repeated a few times.
I3. For N = 21 and a = 4, find the order. What goes wrong?
Powers of 4 modulo 21: 4, 16, 1. The order is r = 3, which is odd. The method needs an even r so that a^(r/2) is an integer, so it fails and you must choose another a. A second try, a = 2, gives r = 6, an even order. Then 2³ = 8, gcd(7, 21) = 7 and gcd(9, 21) = 3, so 21 = 7 × 3. This is the same example as D2, and it shows why random retries are part of the algorithm.
I4. In which two ways can the classical post-processing fail, and what does Shor's algorithm do about it?
First, r may be odd. Second, r may be even but a^(r/2) ≡ −1 (mod N), which gives only the trivial factors 1 and N. In both cases you pick another random a and repeat. For a number with two distinct odd prime factors, the chance that a random a works is at least one half, according to a standard number-theory result that I quote from general knowledge and did not open a source for here. My small tables above are consistent with that: all three cases exceed 50%.
More variational and cost-estimation problems
The last group connects the algorithm lessons to the question that matters for hardware: how many runs does this take? The numbers are simple arithmetic, but they decide whether a method is practical.
Check yourself
J1. For the VQE energy E(θ) = cos θ + 0.5 sin θ, compute the gradient at θ = 2 with the parameter-shift rule and compare with the exact derivative.
Parameter shift: dE/dθ = [E(θ + π/2) − E(θ − π/2)] / 2. Exactly, E′(θ) = −sin θ + 0.5 cos θ. At θ = 2 both give −1.1174 (computed: −1.117371 by both methods). The shift rule needs two extra circuit evaluations per parameter and no small step size, which avoids the noise amplification of finite differences.
J2. What is the minimum of E(θ) = cos θ + 0.5 sin θ? Check it against the smallest eigenvalue of H = Z + 0.5X.
The minimum of a cos θ + b sin θ is −√(a² + b²) = −√1.25 = −1.118034. The eigenvalues of Z + 0.5X are ±√(1 + 0.25) = ±1.118034. They agree because the ansatz Ry(θ)|0⟩ can reach the ground state of this one-qubit Hamiltonian exactly. For larger problems the ansatz usually cannot reach the exact ground state, and the gap is the ansatz error.
J3. A VQE energy has single-shot variance 0.27. How many shots are needed for a standard error of 0.01 and of 0.001? If the Hamiltonian needs 40 separate measurement groups, what is the total for 0.01?
Shots = variance / error². For 0.01: 0.27 / 0.0001 = 2,700. For 0.001: 0.27 / 0.000001 = 270,000. With 40 groups at 2,700 shots each, one energy evaluation costs 108,000 shots. In practice the variance differs by group, and the budget is split unevenly, but this estimate sets the scale. An optimiser that needs 200 evaluations then needs about 21.6 million shots. Ten times better accuracy costs a hundred times more shots.
J4. A four-node cycle graph has a best Max-Cut of 4. What is the average cut of a uniformly random assignment, and the ratio to the best?
Each of the 4 edges is cut with probability 1/2, so the average cut is 2. The ratio is 2/4 = 0.5. For comparison, the triangle in E4 has best cut 2 and random average 1.5, ratio 0.75. A QAOA result must beat these baselines to be interesting, and it must be compared with classical heuristics, which often reach the best cut on graphs of this size.
J5. Using the Trotter table from the algorithm design patterns lesson, how many first-order steps does a simulation need for error 0.001?
From my own experiment, the first-order error was about 0.4936 / r. Solving 0.4936 / r = 0.001 gives r ≈ 494 steps. The second-order formula, with error about 0.1475 / r², needs only 13 steps for the same target. The ratio is about 38 in steps, and it grows as the target error shrinks. This is the quantitative reason that practical simulation algorithms use higher-order formulas.
Check your answers in the browser
The widgets below run the exact circuits behind several of the answers. Predict first, then run, then compare with your worked solution. Results use Qiskit's bit order, with qubit 0 on the right.
F3: Grover on four items, exact after one iteration
Run this circuit
Grover on two qubits: one iteration is exact
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
F1-style: three qubits, one and two iterations
Run this circuit
Grover, 3 qubits, one iteration
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
Run this circuit
Grover, 3 qubits, two iterations
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
G1 and G3: Deutsch–Jozsa and Bernstein–Vazirani
Run this circuit
Deutsch–Jozsa, balanced f(x) = x₀ ⊕ x₁
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
Run this circuit
Bernstein–Vazirani, secret s = 101
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
H1 and H2: phase estimation with an exact and an inexact phase
Run this circuit
Phase estimation of the T gate (exact case)
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
Run this circuit
Phase estimation when the phase does not fit (φ = 1/3)
Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.
Press Run to simulate. Results appear here with a short explanation.
If a widget disagrees with your hand calculation, the usual causes are the bit order, an off-by-one in the iteration count, or reading the wrong register. Work out which before you look at the answer again. The point of a practice set is the habit of reconciling two methods, not the final number.
How to use this practice set well
A practice set only helps if you attempt the problem before you open the solution. A short routine works well:
- Cover the solution and write down your method in one line before any arithmetic.
- Estimate the answer's size first. For a Grover probability it must lie between 0 and 1; for a shot count it should scale with the inverse square of the error.
- Compute. Then open the solution and compare the method, and not only the final number.
- If you were wrong, write the cause in one sentence: formula, arithmetic, bit order or misread question.
- Re-do the problem three days later without looking. Retrieval practice is more effective than re-reading, according to the general research literature on learning, which I did not review for this lesson.
Tally your errors over a set. Most people find that one cause dominates. If it is bit order, practise by running the widgets. If it is the formula, write it on a card. If it is arithmetic, use code. Each cause has a different cure, and diagnosing yours is faster than doing more problems at random.
What to study next
If the Grover and phase-estimation problems were comfortable, move on to the hardware practice set, where the arithmetic is about error rates and fidelities. If the order-finding problems were hard, review the modular arithmetic in the Shor lesson, because everything else in the algorithm depends on it.
Answer key
| Problem | Final answer |
|---|---|
| A1 | Best k = 2, P = 0.9453 |
| A2 | ≈ 804 Grover iterations vs 524,288 classical |
| A3 | ≈ 13 iterations |
| B1 | 5 classical queries vs 1 |
| B2 | 101 with 1 query |
| C1 | Equal magnitudes; phases k/8 |
| C2 | 011 with P = 1 |
| C3 | 0101 with P = 0.8756 |
| D1 | 15 = 3 × 5 via order 4 |
| D2 | 21 = 7 × 3 via order 6 |
| D3 | order 2; 15 = 3 × 5 |
| D4 | Peaks overlap; t too small |
| E1 | Minimum −1.118034 |
| E2 | −0.57132 |
| E3 | 2,700 and 270,000 shots |
| E4 | Average 1.5, ratio 0.75 |
| F1 | k = 3, P = 0.9613 |
| F2 | Same as F1: k = 3, P = 0.9613 |
| F3 | k = 1 gives P = 1; k = 2 gives 0.25 |
| F4 | k = 12, P = 0.9999 |
| F5 | About 823,550 iterations |
| G1 | 513 classical vs 1 quantum |
| G2 | 0.0625 at k = 5; about 0.002 at k = 10 |
| G3 | 20 classical vs 1 quantum |
| G4 | Two CNOTs; result 110 |
| H1 | 011 with 0.6878 |
| H2 | Best outcome settles near 0.684 |
| H3 | t = 9 at minimum |
| H4 | 10 Hadamards and 45 controlled rotations |
| H5 | Uniform 1/√8; phases alternate for |4⟩ |
| I1 | 35 = 7 × 5 via order 12 |
| I2 | 6 of 7 values of a work |
| I3 | Order 3 is odd; retry |
| I4 | Odd order or a^(r/2) = −1; repeat |
| J1 | −1.1174 |
| J2 | −1.118034 |
| J3 | 2,700 and 270,000 shots; 108,000 with 40 groups |
| J4 | Average 2, ratio 0.5 |
| J5 | About 494 first-order steps vs 13 second-order |
Quick answer key.
References and further reading
All results are my own calculations. The Grover formula sin²((2k+1)θ) with θ = arcsin(1/√N) is the standard one; I did not open a source for it in this session,. I evaluated it directly in code and did not run a separate simulation of Grover’s circuit for this set.