Before we formally present the code for the Deutsch-Jozsa (DJ) algorithm, let’s go back to the start of this chapter, where we covered oracles. The astute reader would have noticed that the DJ algorithm creates an oracle when defining this function . In fact, we packaged the functionality of within a black box that we queried with superposition and received outputs from. We measured those outputs to reveal something about the nature of the oracle, as we stipulated that we would when we first read about oracles.
This creation of oracles and then querying them is a powerful technique in quantum computing, and many other algorithms use it. But before diving into those, let’s close off this discussion of the DJ algorithm.
As a refresher, let’s see the circuit for the constant and balanced function . For constant, recall that we would not have the operation or the on the ancilla. It just returns . So, the circuit for that is as follows:
Get hands-on with 1400+ tech skills courses.