  We construct a quantum algorithm that performs function-dependent phase
transform and requires no initialization of an ancillary register. The
algorithm recovers the initial state of an ancillary register regardless of
whether its state is pure or mixed. Thus we can use any qubits as an ancillary
register even though they are entangled with others and are occupied by other
computational process. We also show that our algorithm is optimal in the sense
of the number of function evaluations.
