This project implements the Deutsch–Jozsa quantum algorithm using Qiskit.
It demonstrates how a quantum computer can determine whether a black-box function is constant or balanced in just one query, while a classical computer may require multiple queries.
An interstellar probe has returned with a mysterious crystalline artifact — a "quantum box" that takes a 3-bit input and returns either 0 or 1.
Two scientific theories exist:
- Beacon Theory: The box is constant — always outputs the same value for all inputs.
- Library Theory: The box is balanced — outputs
0for half of the inputs and1for the other half.
The goal is to determine which theory is correct using as few queries as possible.
The Deutsch–Jozsa algorithm is used:
- It initializes the qubits in a superposition.
- Calls the oracle (the “black-box” function) only once.
- Then measures the result.
Interpretation of Results:
- If the measured output is
000→ Function is constant (Beacon Theory) - If the measured output is anything else → Function is balanced (Library Theory)
- Prepare 3 input qubits and 1 ancilla qubit.
- Initialize the ancilla in the
|1⟩state. - Apply Hadamard gates to create superposition.
- Apply the oracle (the box).
- Apply Hadamard gates again on input qubits.
- Measure input qubits.
This was my first quantum computing project, and I learned a lot while implementing the Deutsch–Jozsa algorithm. I explored concepts like quantum gates, oracles and their functions, and also learned how to install and set up Qiskit.
To be completely honest, I tried my best to write the code on my own, but some parts were still confusing. I used ChatGPT to understand and complete certain sections. I hope you’ll understand — I’m still learning and will keep practicing to get better.
Thank you for reading!
-Anushri Maheshwari