When you do long division on paper, you can cross out a side calculation and keep going. In a quantum program, a spare qubit that holds a side calculation can stay linked to the data qubit you still need. Ignoring that spare qubit can make a later operation behave differently. Programmers often clear it by reversing the operations that wrote on it. The technique is called uncomputation.
If you are still getting comfortable with qubits and measurement, start with The Quantum Journal FAQ. Then follow this small example.
Give the data qubit a scratchpad
Imagine an ideal circuit with a data qubit and a scratch qubit, both initially 0. Apply a Hadamard gate to the data qubit. For this particular input, the gate creates a superposition with equal chances of 0 and 1 at measurement. Now use the data qubit as the control of a controlled-NOT gate: in the 1 part of the superposition it flips the scratch qubit, and in the 0 part it leaves the scratch qubit alone. The result is a linked state of both qubits.
The scratch qubit now holds a clue about which alternative the data qubit took. Try applying Hadamard again to the data qubit while leaving that clue in place. In the ideal example, measuring the data qubit now gives 0 or 1 with equal probability. The alternatives cannot fully combine on the data qubit alone because the scratch qubit still distinguishes them.
Go back one operation first
Start the exercise over, and run the controlled-NOT twice instead of once. The second flip undoes the first, returning the scratch qubit to 0 and removing its link to the data. Now the final Hadamard returns the data qubit to 0 with certainty in the ideal circuit. No measurement of the scratch qubit was needed.
This toy circuit does not calculate anything useful. The pattern matters in a bigger program: make a temporary result, use it to change another part of the calculation, then undo only the operations that produced the temporary result. IBM’s worked Grover lesson uses that pattern to mark answers while returning its workspace to 0. Before comparing how many gates two quantum algorithms need, check whether their totals include the work that has to be undone.