Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Understand what separates quantum algorithms from classical algorithms: complexity classes BPP vs BQP, and true quantum speedup.
Interactive 3D state vector exploration, unitary transformation gates, and Born rule collapse for Topic 7.1
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Bounded-Error Probabilistic Polynomial-Time | What ordinary classical computers can solve efficiently within reasonable time | |
| Bounded-Error Quantum Polynomial-Time | What quantum computers can solve efficiently using polynomial-depth quantum circuits | |
| Polynomial Space Complexity | Problems solvable with a reasonable amount of memory, regardless of execution time | |
| Subset relation | Every problem solvable classically in BPP is also solvable quantumly in BQP (BPP β BQP) |
Comparing classical vs quantum runtime scaling for factoring an RSA-2048 key (N = 2^2048):
Result: Transforms an intractable calculation taking billions of years into a computation that finishes in hours.
Initialize register into simultaneous linear combination of all candidate inputs.
Evaluate objective function into quantum phases without collapsing superposition.
Apply unitary transformations to constructively interfere winning solutions.
Measure register to extract optimal answer with bounded error probability > 2/3.
Problem: Evaluating post-quantum encryption standards against BQP complexity bounds.
Solution: National security agencies verify that lattice-based cryptography remains hard even for BQP algorithms.
Interactive activity component
Construct the standard 3-stage template of a quantum algorithm in Qiskit and trace statevector transformations.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install qiskit qiskit-aer1 from qiskit import QuantumCircuit 2 from qiskit.quantum_info import Statevector
from qiskit import QuantumCircuit β Circuit module
from qiskit.quantum_info import Statevector β Statevector module
1 # Standard 3-stage quantum algorithm structure: 2 # Stage 1: Initialization into equal superposition 3 qc = QuantumCircuit(2, 2) 4 qc.h([0, 1]) # Parallel superposition across |00>, |01>, |10>, |11> 5 print('Stage 1 - Uniform Superposition:', Statevector.from_instruction(qc).data.round(2)) 6 7 # Stage 2: Quantum Oracle (marks target state |11> with -1 phase) 8 qc.cz(0, 1) # Controlled-Z flips phase of |11> 9 print('Stage 2 - After Oracle Marking:', Statevector.from_instruction(qc).data.round(2)) 10 11 # Stage 3: Interference / Diffusion (Amplifies marked state) 12 qc.h([0, 1]) # Recombination via Hadamards 13 print('Stage 3 - After Interference:', Statevector.from_instruction(qc).data.round(2)) 14 print('\nCircuit Diagram:') 15 print(qc.draw('text'))
# Standard 3-stage quantum algorithm structure:
3 stages
# Stage 1: Initialization into equal superposition
Stage 1
qc = QuantumCircuit(2, 2)
2 qubits, 2 bits
qc.h([0, 1]) # Parallel superposition across |00>, |01>, |10>, |11>
H on all
print('Stage 1 - Uniform Superposition:', Statevector.from_instruction(qc).data.round(2))
Stage 1 state
# Stage 2: Quantum Oracle (marks target state |11> with -1 phase)
Stage 2
qc.cz(0, 1) # Controlled-Z flips phase of |11>
CZ oracle
print('Stage 2 - After Oracle Marking:', Statevector.from_instruction(qc).data.round(2))
Stage 2 state
# Stage 3: Interference / Diffusion (Amplifies marked state)
Stage 3
qc.h([0, 1]) # Recombination via Hadamards
Hadamard recombination
print('Stage 3 - After Interference:', Statevector.from_instruction(qc).data.round(2))
Stage 3 state
print('\nCircuit Diagram:')
Diagram label
print(qc.draw('text'))
Draw circuit
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Structure of a Quantum Algorithm in Qiskit: Initialization, Oracle & Interference 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install qiskit qiskit-aer 8 9 # Step 2: Import libraries 10 from qiskit import QuantumCircuit 11 from qiskit.quantum_info import Statevector 12 13 # Step 3: Run Demonstration 14 # Standard 3-stage quantum algorithm structure: 15 # Stage 1: Initialization into equal superposition 16 qc = QuantumCircuit(2, 2) 17 qc.h([0, 1]) # Parallel superposition across |00>, |01>, |10>, |11> 18 print('Stage 1 - Uniform Superposition:', Statevector.from_instruction(qc).data.round(2)) 19 20 # Stage 2: Quantum Oracle (marks target state |11> with -1 phase) 21 qc.cz(0, 1) # Controlled-Z flips phase of |11> 22 print('Stage 2 - After Oracle Marking:', Statevector.from_instruction(qc).data.round(2)) 23 24 # Stage 3: Interference / Diffusion (Amplifies marked state) 25 qc.h([0, 1]) # Recombination via Hadamards 26 print('Stage 3 - After Interference:', Statevector.from_instruction(qc).data.round(2)) 27 print('\nCircuit Diagram:') 28 print(qc.draw('text'))
Initialize all input qubits into uniform superposition with Hadamard gates.
Encode problem constraints or target solutions into relative phase angles.
Recombine wave paths to constructively amplify correct answers.
QuantumCircuit(2, 2) executing the 3 core stages of a quantum algorithm.
Stage 1: [0.5, 0.5, 0.5, 0.5] Stage 2: [0.5, 0.5, 0.5, -0.5] (Target |11> marked with -0.5) Stage 3: Interference transforms state.
Every major quantum algorithmβfrom Grover search to Shor factoringβfollows this three-stage pipeline: superposition initialization, oracle phase-marking, and wave interference readout.
Oracle, diffusion operator, interference, and quadratic search speedup.
Test your understanding with these questions. Remember, this is for learning, not examination!