The Deutsch-Jozsa algorithm
Deutsch's algorithm outperforms all classical algorithms for a query problem, but the advantage is quite modest: one query versus two. The Deutsch-Jozsa algorithm extends this advantage — and, in fact, it can be used to solve a couple of different query problems.
Here's a quantum circuit description of the Deutsch-Jozsa algorithm. An additional classical post-processing step, not shown in the figure, may also be required depending on the specific problem being solved.
Of course, we haven't actually discussed what problems this algorithm solves; this is done in the two sections that follow.
The Deutsch-Jozsa problem
We'll begin with the query problem the Deutsch-Jozsa algorithm was originally intended to solve, which is known as the Deutsch-Jozsa problem.
The input function for this problem takes the form for an arbitrary positive integer Like Deutsch's problem, the task is to output if is constant and if is balanced, which again means that the number of input strings on which the function takes the value is equal to the number of input strings on which the function takes the value .
Notice that, when is larger than there are functions of the form that are neither constant nor balanced. For example, the function defined as
falls into neither of these two categories. For the Deutsch-Jozsa problem, we simply don't worry about functions like this — they're considered to be "don't care" inputs. That is, for this problem we have a promise that is either constant or balanced.
The Deutsch-Jozsa algorithm, with its single query, solves this problem in the following sense: if every one of the measurement outcomes is then the function is constant; and otherwise, if at least one of the measurement outcomes is then the function is balanced. Another way to say this is that the circuit described above is followed by a classical post-processing step in which the OR of the measurement outcomes is computed to produce the output.
Algorithm analysis
To analyze the performance of the Deutsch-Jozsa algorithm for the Deutsch-Jozsa problem, it's helpful to begin by thinking about the action of a single layer of Hadamard gates. A Hadamard operation can be expressed as a matrix in the usual way,
but we can also express this operation in terms of its action on standard basis states:
These two equations can be combined into a single formula,
which is true for both choices of
Now suppose that instead of just a single qubit we have qubits, and a Hadamard operation is performed on each. The combined operation on the qubits is described by the tensor product ( times), which we write as for conciseness and clarity. Using the formula from above, followed by expanding and then simplifying, we can express the action of this combined operation on the standard basis states of qubits like this: