Solution

ID: past-exam-of-the-laser-science-and-quantum-information-processing-course-of-the-university-of-oxford/2006/5/3/solution

For brackets the control-zero branch still does nothing, and the control-one branch applies to the target. Immediately before the final two Hadamard gates, the quantum state is
For the constant function with , the phase oracle is , so . Since is an eigenstate of the Pauli X gate with eigenvalue , for every integer . The final two Hadamard gates therefore give
In particular, the first qubit always ends in .
For the constant function with , and , so . Thus the target remains in , and the top qubit before its final Hadamard gate is . The sign is a relative quantum phase between the control branches. The Hadamard gate converts it into the integer parity of :
The first qubit is therefore for even and for odd , including all requested .

New to topics? Read the docs here!