Explain the role of interference in the Deutsch-Jozsa algorithm — specifically, why does the final Hadamard transform on the input register produce |0...0> for constant functions but never |0...0> for balanced functions?
Think about your answer, then reveal below.
Model answer: After the oracle, each computational basis state |x> has acquired a phase (-1)^f(x). The final Hadamard transform on n qubits maps each |x> to a superposition over all basis states. The amplitude of |0...0> in the output is the sum of (-1)^f(x) over all x, divided by 2^n. If f is constant, all phases are the same and the sum is +/-1, giving probability 1 for |0...0>. If f is balanced, half the phases are +1 and half are -1, so the sum is exactly zero, giving probability 0 for |0...0>.
This is a clean example of constructive and destructive interference. The Hadamard transform recombines all 2^n amplitude paths, and the phases imposed by the oracle determine whether they add up or cancel. A constant function produces coherent addition (constructive interference at |0...0>), while a balanced function produces perfect cancellation (destructive interference at |0...0>). This interference pattern lets a single measurement distinguish the two cases with certainty.