Bernstein-Vazirani Algorithm

348dc0d6-16a8-4eb1-8ee4-b74a5ced00a3
4.0
Description

This quantum circuit implements the Bernstein-Vazirani algorithm to identify a hidden binary string, specifically '1011', in a single query.

Qiskit Circuit Code
Python
```python
from qiskit import QuantumCircuit

# Bernstein-Vazirani Algorithm with secret string '1011'
qc = QuantumCircuit(5, 4)

# Initialize the ancilla qubit in state |1⟩
qc.h(4)
qc.z(4)

# Apply Hadamard gates to the first 4 qubits
qc.h(range(4))

# Oracle implementation for secret string '1011'
secret_string = '1011'
for i, bit in enumerate(secret_string):
    if bit == '1':
        qc.cx(i, 4)

# Apply Hadamard gates again to the first 4 qubits
qc.h(range(4))

# Measure the first 4 qubits
qc.measure(range(4), range(4))
```
Quantum Execution Results
ibm_kyiv
unknown
1024 shots
Measurement Counts
{
  "0000": 3,
  "0001": 1,
  "0101": 18,
  "1000": 1,
  "1001": 46,
  "1100": 11,
  "1101": 944
}
Raw Result Data
Download Results
Back to Home