Deutch-Jozza algorithm is a one of the simplest quantum algorithm that solves a particular problem faster than its classical counterpart.
Suppose that there is a binary function , which can be divided into those two following categories.
-
Balanced function If you use this algorithm, you can figure out whether is belonged to which category just by one evaluation, although its classical algorithm takes n trials(n is the binary length of input)
I prepared the oracle in order to judge the function is constant or balanced.
If , this function would be constant and it would be balanced otherwise.
Here, I am going to show quantum circuits and codes that I implemented.
This is the quantum circuit for a constant function
and this is the result on OpenQASM simulator.
Also, this is the result on ibmqtokyo20.
Therefore, this is a constant function.
This is the quantum circuit for a balanced function.
and this is the result on OpenQASM simulator.
This is the result on ibmq20Tokyo.
The outcome is not (in most cases) ,therefore, it can be said that this function is balanced.
I also uploaded implementation for Deutch algorithm, which is the Deutsch-Jozsa algorithm for one qubit, feel free to check my code.