0% found this document useful (0 votes)
20 views4 pages

Bernstein

Brief on algorithm

Uploaded by

Bhushan Waghade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Bernstein

Brief on algorithm

Uploaded by

Bhushan Waghade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Bernstein – Vazirani Algorithm

1. Introduction. The Bernstein-Vazirani algorithm is an quantum algorithm


similar to Deustch – Josza algorithm.

2. Deustch – Josza algorithm distinguishes whether the given function is constant


or balanced, but this Bernstein – Vazirani algo instead finds information about linear
Boolean function of the blackbox.

3. The computing speed up is achieved by this algorithm as it takes only one call
to identify the function unlike its classical approach where it requires ‘n’ queries (for n
bit).

4. Problem Statement. Given a function evaluator which takes input x as n


bit binary number and gives output as function of x such that
f(x) = a.x
The problem is to determine ‘a’ and dot represents bitwise modulo 2 addition.

Comments on Algorithm.

5. The algorithm uses the key concepts of quantum parallelism and quantum
interference. First the n bit input state is initialised to |0> and is then prepared in equal
superposition state by applying Hadamard gate on all the n qubits. In this step all 2n
inputs are prepared and then evaluated by the unitary function Uf and hence quantum
parallelism is achieved.

6. Hadamard gates after the unitary function black box destroys all output values
except for ‘a’ which is the required solution.

7. This problem is trivial as for demonstration purpose known value of a is taken


into consideration to build the oracle. But it is a very good demonstration of quantum
speedup that achieved when compared to classical algorithms.

Circuit Implementation

8. Let us consider, for above problem statement, a = 11001.

9. The input qubits is initialised to 0 and target output is initialised to 1 and created
in superposition using Hadamard gate. The circuit for the given value of a is as shown
below.
bernstein vazirani about:srcdoc

a=input("Input the value of a:")

from qiskit import QuantumCircuit


circ= QuantumCircuit(len(a)+1,len(a))
#applying hadamard to all the input and creating superposition
circ.h(range(len(a)))
circ.x(len(a))
circ.h(len(a))
circ.barrier()
circ.draw('mpl')

#creating an oracle unitary function that performs CX gate for each '1' in secret bit string
for digit, query in enumerate((reversed(a))):
if query=="1":
circ.cx(digit, len(a))

circ.barrier()
circ.draw('mpl')

1 of 3 11/10/23, 14:53

You might also like