Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2022/ii/paper-3/10d/b/solution

With the restricted operations, begin in and apply to the first register:
Now apply
For every basis state this compute-phase-uncompute construction acts as
The first register is therefore the same phase state used in part (a). Apply and measure. Again, outcome occurs with probability one for a constant string and probability zero for a balanced string. The construction uses exactly two queries to and only the permitted operations.

New to topics? Read the docs here!