Introduction to Quantum Computing

Chapter 7
Foundations of Quantum Algorithms

Diploma in Quantum Computing
Introduction to Quantum Computing   •   Diploma

Foundations of Quantum Algorithms

Introduction and Context

Quantum algorithms exploit the principles of quantum mechanics to process information in ways that have no direct classical equivalent. Their advantage does not arise simply because a quantum computer evaluates every possible answer and then reads them all. Measurement still produces only one outcome. The central design problem is therefore to arrange quantum amplitudes so that desirable outcomes become more likely and undesirable outcomes interfere destructively.

This chapter introduces four ideas that recur throughout quantum algorithm design:

  1. Oracle models, which represent a problem-dependent operation without specifying its internal implementation.
  2. Amplitude manipulation, especially interference produced by unitary transformations.
  3. Phase kickback, in which information about a function is transferred from a target qubit to a phase on a control state.
  4. Quantum parallelism, the evaluation of a function on a superposition of inputs.

These ideas are developed through the Deutsch–Jozsa, Bernstein–Vazirani, and Simon algorithms. These algorithms are mainly pedagogical and demonstrate query-complexity advantages rather than immediate commercial applications. Nevertheless, they establish design patterns used in more advanced algorithms.

Learning Objectives

By the end of this chapter, a learner should be able to:

  • distinguish a quantum oracle from a complete quantum algorithm;
  • explain how superposition, interference, and measurement interact;
  • derive the phase-kickback identity;
  • trace the main steps of the Deutsch–Jozsa algorithm;
  • explain why Bernstein–Vazirani identifies a hidden bit string with one oracle query;
  • describe the hidden-period structure in Simon’s algorithm;
  • identify assumptions, limitations, and implementation concerns in oracle-based algorithms.

1. The Oracle Model

An oracle is an abstract operation that provides access to a problem-dependent function. In classical query complexity, an algorithm may ask for the value of a function f(x) at selected inputs. The cost is measured by the number of queries, while computation between queries may be treated separately.

For a Boolean function f:{0,1}n→{0,1}, the standard reversible quantum oracle is defined by

Uf|x⟩|y⟩ = |x⟩|y ⊕ f(x)⟩

Here, x is an n-bit input, y is a target bit, and ⊕ denotes addition modulo 2. The transformation is reversible because applying it twice restores the original state:

Uf2 = I

where I is the identity operation. Reversibility is required because every closed-system quantum operation is unitary. A map that simply changes |x⟩ into |f(x)⟩ is generally not reversible when multiple inputs have the same output, so the target register preserves the required information.

For a superposition, linearity gives

Uf(∑x αx|x⟩|y⟩) = ∑x αx|x⟩|y ⊕ f(x)⟩

The amplitudes αx are complex numbers satisfying the normalization condition

∑x |αx|2 = 1

when the state is normalized. The quantity |αx|2 is the probability of observing basis state |x⟩ if measurement is performed in the computational basis.

An oracle is a model, not necessarily a cheap physical component. In a real device, constructing Uf may require many gates, additional qubits, error correction, and problem-specific data loading. A query advantage is meaningful only when oracle construction and implementation costs are also considered.

2. Superposition, Amplitudes, and Interference

A single qubit can be written as

|ψ⟩ = α|0⟩ + β|1⟩

with |α|2 + |β|2 = 1. Measurement gives 0 with probability |α|2 and 1 with probability |β|2. Amplitudes, unlike probabilities, can be negative or complex. This permits interference.

If two computational paths lead to the same final basis state, their amplitudes add. For example, amplitudes a and b produce a final amplitude a+b. The probability is

P = |a+b|2

If a and b have the same phase, they may reinforce each other. If they have opposite phase, they may cancel. This is the mechanism by which a quantum algorithm converts hidden information into measurable probability differences.

The Hadamard gate is especially important:

H|0⟩ = (|0⟩+|1⟩)/√2
H|1⟩ = (|0⟩−|1⟩)/√2

For an n-qubit register, applying a Hadamard gate to every qubit creates

H⊗n|0n⟩ = (1/√(2n))∑_{x∈{0,1}n}|x⟩

This is a uniform superposition over all 2n inputs. The expression describes amplitudes, not 2n simultaneously readable classical answers.

3. Phase Kickback

Phase kickback is the transfer of a function-dependent phase to the input register. Prepare the target qubit in the state

|−⟩ = (|0⟩−|1⟩)/√2

Using the oracle definition,

Uf|x⟩|−⟩ = (−1)f(x)|x⟩|−⟩

To verify this, consider the two possible values of f(x). If it is 0, the target is unchanged. If it is 1, the oracle swaps |0⟩ and |1⟩, which changes |−⟩ to −|−⟩. Thus the target returns to its original state while the input acquires a phase.

For a superposed input, the result is

Uf(∑x αx|x⟩|−⟩) = ∑x αx(−1)f(x)|x⟩|−⟩

This is valuable because a phase cannot be observed directly in a single measurement of a basis state. It must first be converted into amplitude differences by further gates, commonly Hadamard gates.

4. Quantum Parallelism as an Algorithmic Resource

Quantum parallelism refers to applying a unitary operation to a superposition of inputs. If the input register is in a uniform superposition, one oracle call produces function-dependent information across all basis components. However, the result remains a single quantum state, and measurement reveals only limited information.

Effective algorithms therefore have three stages:

  1. Encode many candidate inputs in amplitudes.
  2. Transform amplitudes using an oracle and interference-producing gates.
  3. Extract a global property through measurement.

The advantage is strongest when the required output is a global property—such as whether a function is constant or balanced, or a hidden relation among inputs—rather than a complete list of function values.

5. Deutsch–Jozsa Algorithm

Problem definition

Let f:{0,1}n→{0,1} be promised to be either:

  • constant: the same value for every input; or
  • balanced: 0 for exactly half the inputs and 1 for the other half.

The task is to determine which case holds. The promise is essential. If arbitrary functions were allowed, the two-query classification problem would be a different task.

A deterministic classical algorithm may require 2n−1+1 queries in the worst case. After observing more than half of all inputs with no decisive imbalance, the promise forces the classification. The Deutsch–Jozsa quantum algorithm uses one oracle query in the query model.

Circuit logic

Start with

|0n⟩|1⟩

Apply Hadamards to all qubits. The state becomes

(1/√(2n))∑x|x⟩|−⟩

The oracle applies phase kickback:

(1/√(2n))∑x(−1)f(x)|x⟩|−⟩

Apply H⊗n to the input register. The amplitude of |z⟩ is

Az = (1/2n)∑x(−1)f(x)+x·z

where x·z is the bitwise inner product modulo 2:

x·z = x1z1 ⊕ x2z2 ⊕ ⋯ ⊕ xnzn

For z=0n, this reduces to

A0n = (1/2n)∑x(−1)f(x)

If f is constant, every term has the same sign, so |A0n|=1 and the input register is measured as 0n. If f is balanced, half the terms are +1 and half are −1, so A0n=0. Therefore, measuring 0n indicates constant, while any other result indicates balanced.

Small example

For n=2, suppose f(x)=x1; the function is balanced. The four phase signs are:

Input xf(x)Phase (−1)f(x)
000+1
010+1
101−1
111−1

The sum of the signs is zero, so the amplitude of |00⟩ after the final Hadamards is zero. The algorithm consequently never reports the constant outcome under ideal conditions.

6. Bernstein–Vazirani Algorithm

Hidden-string problem

A hidden string s∈{0,1}n defines the function

fs(x) = s·x mod 2

The goal is to determine s. Classically, querying each standard basis vector ei reveals one bit because fs(ei)=si. Thus n classical queries suffice, and in the standard deterministic model n are necessary.

The Bernstein–Vazirani algorithm uses one quantum query. Prepare the input in a uniform superposition and the target in |−⟩. Phase kickback yields

(1/√(2n))∑x(−1)s·x|x⟩|−⟩

The final Hadamard transform uses the identity

H⊗n(1/√(2n))∑x(−1)s·x|x⟩ = |s⟩

Therefore measurement returns s with certainty in the ideal oracle model.

Interpretation

Bernstein–Vazirani illustrates a particularly clean form of interference. The phase pattern generated by the oracle is itself a Walsh–Hadamard character indexed by s. The final Hadamards decode that pattern into the computational basis state |s⟩. The result should not be interpreted as obtaining all function values independently; it obtains a structured global parameter encoded in the phase pattern.

7. Simon’s Algorithm and Hidden Periodicity

Simon’s problem concerns a function f:{0,1}n→{0,1}n with a hidden nonzero string s such that

f(x)=f(y) if and only if y=x⊕s

Thus every output has exactly two preimages, separated by s. The task is to discover s.

The algorithm begins with |0n⟩|0n⟩. Hadamards on the first register create a superposition, and the oracle produces

(1/√(2n))∑x|x⟩|f(x)⟩

Measuring the second register would leave the first register in a state proportional to

|x⟩ + |x⊕s⟩

Applying Hadamards to the first register produces outcomes y satisfying

y·s = 0 mod 2

Each run supplies one random linear equation in the unknown bits of s. Repeating the experiment produces equations

y(1)·s=0,
y(2)·s=0,
…

Solving these equations over the binary field GF(2) yields s. Since the equations are random subject to the orthogonality condition, approximately n independent equations are typically required, with additional repetitions possible because sampled equations may be dependent.

Why Simon’s algorithm matters

Simon’s algorithm demonstrates an exponential separation in the black-box query model: its quantum query complexity is polynomial in n, whereas randomized classical algorithms require exponentially many queries in the worst-case formulation. It also introduces a central algorithmic pattern: create a superposition of related inputs, use interference to impose a constraint, repeat to collect enough linear information, and solve a classical algebra problem.

8. Comparison of the Three Algorithms

AlgorithmHidden propertyOracle typeQuantum query patternClassical comparison
Deutsch–JozsaConstant versus balancedBoolean functionOne queryUp to 2n−1+1 deterministic queries
Bernstein–VaziraniHidden string sLinear Boolean functionOne queryn queries
SimonPeriod sTwo-to-one vector functionRepeated sampling and linear solvingExponentially many queries in the black-box model

The algorithms differ in the information extracted. Deutsch–Jozsa determines a promise-class property, Bernstein–Vazirani recovers a linear parameter, and Simon’s algorithm gathers constraints on a hidden period.

9. Illustrative Applied Scenario: Testing an Abstract Device Interface

The following is a fictional illustrative case, not a claim about a current commercial product.

Background

A research laboratory receives access to an abstract device that evaluates an unknown Boolean interface f(x). The interface is guaranteed either to return the same bit for all x or to be balanced.

Problem

The laboratory wants to classify the interface while minimizing costly device calls. A classical engineer tests inputs one at a time. For large n, a decisive classical test may require more than half of the possible inputs.

Quantum approach

The engineer implements a reversible oracle, initializes an n-qubit input register in a uniform superposition, prepares an ancilla in |−⟩, performs one oracle call, and applies final Hadamards. The measurement of 0n is interpreted as constant; any other result is interpreted as balanced.

Analysis and outcome

Under the promise, ideal gates, and a correct oracle, the classification succeeds with certainty. In a laboratory, however, repeated executions may be needed because gate noise and readout error can produce an incorrect result. The oracle’s synthesis cost may also dominate the circuit. Consequently, the query advantage does not automatically imply a lower total engineering cost.

Learning points

  • The promise defines what conclusions are valid.
  • Oracle complexity and physical implementation complexity are distinct.
  • Interference converts phase information into a measurable result.
  • Practical benchmarking must include state preparation, oracle construction, error mitigation, and measurement overhead.

10. Implementation, Limitations, and Best Practices

Implementation considerations

A practical circuit must account for qubit connectivity, gate fidelity, coherence time, compilation overhead, and measurement error. Multi-controlled operations used in oracle construction may require decomposition into native gates. Ancilla qubits can reduce circuit depth in some designs but increase hardware demands.

Common conceptual errors

First, quantum parallelism is not equivalent to reading all function values simultaneously. Second, global phase has no observable effect by itself; only relative phase affects interference. Third, a query-count advantage assumes that the oracle is available as a permitted operation. Fourth, a promise problem must not be presented as an unrestricted classification problem.

Noise and probability

Ideal analyses often predict a deterministic output. Noisy hardware produces a distribution of outcomes. If an outcome is observed k times in N independent shots, its empirical frequency is k/N. This is an estimator, not a guarantee that the ideal algorithm is correct. Error mitigation and statistical confidence analysis are required for practical experiments.

Ethical and governance considerations

Quantum algorithms can eventually affect cryptography, scientific simulation, optimization, and national security. Responsible practice requires accurate claims about quantum advantage, transparent reporting of hardware limitations, protection of sensitive oracle data, and avoidance of presenting toy demonstrations as deployable solutions. For cryptographic applications, organizations should plan migration to post-quantum cryptographic standards even though the algorithms in this chapter are not themselves cryptanalytic tools.

Contemporary Direction

Current quantum algorithm research extends these foundations through amplitude amplification, quantum walks, quantum simulation, variational algorithms, and error-corrected fault-tolerant computation. The recurring question remains the same: what structure can be encoded into amplitudes or phases, and what transformation will make that structure measurable? Future progress depends not only on algorithmic ideas but also on fault-tolerant resource estimates, efficient data loading, and fair comparison with the best classical methods.

Chapter Summary

Oracle models provide an abstract interface to problem data while preserving reversibility through transformations such as Uf|x⟩|y⟩=|x⟩|y⊕f(x)⟩. Quantum parallelism applies an oracle to a superposition, but useful computation requires interference to amplify relevant outcomes and cancel irrelevant ones. Preparing the target in |−⟩ produces phase kickback, transforming function values into phases (−1)f(x).

The Deutsch–Jozsa algorithm distinguishes constant and balanced Boolean functions with one query under a promise. Bernstein–Vazirani uses one query to recover a hidden linear bit string. Simon’s algorithm repeatedly obtains equations orthogonal to a hidden period and solves them over GF(2). These examples demonstrate that quantum advantage depends on problem structure, oracle assumptions, and the cost of physical implementation. They also establish a general design method: encode, query, interfere, measure, and classically interpret the result.

Key Terms

Oracle: A problem-dependent reversible operation used as an abstract query interface.

Unitary operation: A norm-preserving reversible quantum transformation.

Quantum parallelism: Applying an operation to a superposition of many basis inputs.

Amplitude: A complex coefficient associated with a quantum basis state.

Probability amplitude: An amplitude whose squared magnitude gives measurement probability.

Interference: Addition of amplitudes that can reinforce or cancel outcomes.

Phase: The complex-angle information carried by an amplitude.

Phase kickback: Transfer of a function-dependent phase from a target operation to a control state.

Hadamard gate: A gate that converts computational basis states into equal superpositions.

Balanced function: A Boolean function returning 0 and 1 equally often.

Constant function: A function returning the same value for every input.

Promise problem: A computational problem whose valid inputs satisfy a stated restriction.

Hidden string: An unknown bit string encoded in a function, as in Bernstein–Vazirani.

Hidden period: A nonzero string defining a relation between equal function outputs.

Bitwise inner product: The modulo-2 sum of pairwise bit products.

Walsh–Hadamard transform: The multi-qubit transformation produced by tensor products of Hadamard gates.

Query complexity: The number of oracle calls made by an algorithm.

Ancilla: An auxiliary qubit used to support computation.

Global phase: A common phase factor that does not affect measurement probabilities.

Relative phase: A phase difference that can affect interference and measurement outcomes.

Review Questions

5 Short Answer Questions

  1. Why must a quantum oracle be reversible?
  2. What is the probability of measuring |1⟩ in the state α|0⟩+β|1⟩?
  3. Explain why the target state |−⟩ is useful for phase kickback.
  4. What promise is made in the Deutsch–Jozsa problem?
  5. What type of equations are collected in Simon’s algorithm?

5 Long Answer Questions

  1. Explain how superposition and interference work together in an oracle-based algorithm.
  2. Derive the phase-kickback identity for Uf|x⟩|−⟩.
  3. Describe the complete Deutsch–Jozsa circuit and justify its measurement rule.
  4. Compare the query complexities and hidden structures of Deutsch–Jozsa, Bernstein–Vazirani, and Simon’s algorithms.
  5. Discuss why an oracle query advantage may not translate directly into a practical runtime advantage.

3 Analytical / Application Questions

  1. For n=3, determine whether the function f(x)=x1⊕x3 is constant or balanced, and predict the Deutsch–Jozsa measurement outcome category.
  2. A Bernstein–Vazirani oracle implements f(x)=x2⊕x4 for four-bit inputs. Identify the hidden string and explain the ideal measurement result.
  3. Suppose Simon’s experiment produces independent equations y·s=0 over GF(2). Explain how Gaussian elimination can be used to recover a nonzero candidate for s, and why dependent equations may require additional runs.

Multiple Choice Questions with Answers

Question 1

What is the standard reversible oracle transformation for a Boolean function?

A. Uf|x⟩|y⟩=|x⟩|y⊕f(x)⟩

B. Uf|x⟩=|f(x)⟩

C. Uf|x⟩|y⟩=|f(x)⟩|x⊕y⟩

D. Uf|x⟩|y⟩=|x⟩|y+f(x)⟩ without modular arithmetic

Correct Answer: A. Uf|x⟩|y⟩=|x⟩|y⊕f(x)⟩

Question 2

What is the probability of measuring |1⟩ in |ψ⟩=α|0⟩+β|1⟩?

A. |α|

B. |β|2

C. α+β

D. 1−|β|2

Correct Answer: B. |β|2

Question 3

Which target state enables phase kickback in the standard Boolean oracle?

A. |0⟩

B. |1⟩

C. |+⟩=(|0⟩+|1⟩)/√2

D. |−⟩=(|0⟩−|1⟩)/√2

Correct Answer: D. |−⟩=(|0⟩−|1⟩)/√2

Question 4

Under the Deutsch–Jozsa promise, what does measurement of 0n indicate?

A. The function is balanced

B. The function is constant

C. The oracle is nonunitary

D. The input register was not initialized

Correct Answer: B. The function is constant

Question 5

How many oracle queries does the ideal Bernstein–Vazirani algorithm require?

A. One

B. n

C. 2n

D. n2

Correct Answer: A. One

Question 6

In Bernstein–Vazirani, the hidden function has the form:

A. fs(x)=s+x over integers

B. fs(x)=s·x mod 2

C. fs(x)=x2+s

D. fs(x)=2s x

Correct Answer: B. fs(x)=s·x mod 2

Question 7

What condition do Simon’s sampled strings typically satisfy?

A. y=s

B. y·s=1 mod 2

C. y·s=0 mod 2

D. y⊕s=0 for every sample

Correct Answer: C. y·s=0 mod 2

Question 8

Why is the map |x⟩→|f(x)⟩ generally unsuitable as a quantum oracle?

A. It always uses too many qubits

B. It may not be reversible when different inputs share an output

C. It cannot represent Boolean functions

D. It produces only real amplitudes

Correct Answer: B. It may not be reversible when different inputs share an output

Question 9

For a normalized qubit, which condition must hold?

A. |α|+|β|=1

B. α+β=1

C. |α|2+|β|2=1

D. αβ=1

Correct Answer: C. |α|2+|β|2=1

Question 10

What is the main role of the final Hadamard transform in these examples?

A. To erase the oracle definition

B. To convert phase patterns into measurable amplitude differences

C. To make measurement unnecessary

D. To create irreversible computation

Correct Answer: B. To convert phase patterns into measurable amplitude differences

Introduction to Quantum Computing
Chapter 7 of 14