Deutsch's algorithm is one of the first presented quantum algorithms that provided a quantum advantage over classical computers for a specific problem.
Problem
Assume we have a function binary , such that
We say function is:
Balanced if .
Constant if .
Using the least numbers of queries to the function , determine if the function is balanced or constant.
Classical Solution
To solve this problem classically we have to query the function two times to get the result of both and . Therefore we need to cover the entire search space / function domain.
Deutsch's Algorithm
We assume we have an oracle that implements the function , call it , as a unitary operation.
The algorithm uses phase kickback to solve the problem with a single query of the oracle. This can be seen in the following implementation of the algorithm.
We notice that a phase kickback will occur when . Now let's apply these gates on our initial state .
Now if is constant (i.e. ), then both the and states would have the same phase, which means it's a global phase and we can ignore it.
Therefore if is constant then the output after measurement is .
Now what if is balanced (i.e. ), then the states and would have opposite phases, therefore it can be represented as .
That means that we would measure if is balanced.
Conclusion
Deutsch's algorithm uses an oracle to implement function , then uses a single query to figure out whether the function is balanced or constant. This is done by employing phase kickback in the oracle implementation, where the result is dependent on a qubit in superposition, therefore we get a different phase kickback depending on the state.
At the end, if the measured result is then is constant, and if the measured result is then is balanced.
Practicality
Deutsch's algorithm is used to prove the existence of a quantum advantage over classical computers, and the algorithm is not used in real applications due to its specific and impractical problem.