The two qubits are initalized in the state
After the two Hadamard operators, the two-qubit state becomes:
The unitary operator Uf encodes the function f into the state of the qubits
After another Hadamard operator on each qubit, the output state depends on the characteristic of the function f:
0 or 1
A measurement of the first qubit will then determinewhether the function f is constant or balanced.
This is how we can tell whether the function is constant or balanced.