From Qubits to Basic Algorithms for Beginners
Swipe up to begin ↑
Classical computers process bits sequentially. Certain tasks, such as factoring large integers or simulating quantum molecules, require exploring an exponentially growing number of possibilities (2n for n bits).
Which problem becomes intractable for classical computers as input size grows?
Factoring large semiprimes is believed to require exponential time on classical machines; the other tasks are efficient (polynomial time).
Create a slider (1–10) that shows two side-by-side panels. Left panel: classical bits — display the exact 2^n possible states but note they must be checked one-by-one. Right panel: qubits — display a single state vector that represents all 2^n possibilities simultaneously via superposition. Update both panels live as the slider moves and show the count of representable states.
A qubit state is written |ψ⟩ = α|0⟩ + β|1⟩, where α and β are complex numbers called amplitudes.
Normalization requires |α|² + |β|² = 1.
Until measured, the qubit exists in both |0⟩ and |1⟩ simultaneously, weighted by α and β. This is superposition.
If |ψ⟩ = (1/√2)|0⟩ + (1/√2)|1⟩, what are the probabilities of measuring 0 or 1?
|α|² = |(1/√2)|² = 1/2, same for β, so each outcome occurs with probability 1/2.
Build a simple calculator: user enters real values for α and β (assume normalized), then on button click display the two possible measurement outcomes and their probabilities |α|² and |β|² as percentages. Show a random measurement result when the user clicks 'Measure'.
Determines if a boolean function f:{0,1}→{0,1} is constant or balanced. Classically needs up to 2 queries; quantum version solves it with one query to the oracle using superposition and interference.
How many oracle queries does Deutsch's algorithm require?
It achieves the result with a single query thanks to quantum parallelism.
Interactive circuit simulator: select constant or balanced oracle, apply Hadamard gates and oracle, measure the first qubit. Display input state, circuit diagram, and final probability of |0⟩ vs |1⟩ to confirm constant (0) or balanced (1) result.