🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Quantum Walk Algorithms

Quantum ComputingQuantum WalksđŸŸĸ Free Lesson

Classical vs Quantum Random Walks

A classical random walk on a graph spreads as . A quantum walk evolves unitarily and spreads as — a quadratic speedup in spreading rate.

The gap is quantitative, not rhetorical. A classical walker flips a fair coin each step, so after steps its displacement has standard deviation and reaching a target at distance costs steps. A quantum walker propagates ballistically: its wavefront moves at bounded group velocity, so the same distance costs steps. After 100 steps a classical walker still sits within about 10 sites of its origin, while the quantum amplitude has already reached sites near .

Two properties make that transport algorithmically useful. Amplitude is preserved rather than spent, so the walker can cover many branches simultaneously and then interfere them: paths that drift away from a target cancel, paths that approach it reinforce. And the evolution is unitary, so the process is reversible and no information is destroyed — the spreading advantage converts into query complexity rather than remaining a physical curiosity. The cost is structure: the probability landscape is spiky, so measuring at the wrong moment returns a poor answer, and every walk has to be timed against how fast the underlying graph mixes.

Discrete-Time Quantum Walks

A discrete-time quantum walk uses coin and position registers:

The coin operator determines direction, and the shift operator moves the walker:

The walk step alternates coin operations and shifts, and the choice of coin changes the physics. The Hadamard coin is the default on a line because it splits the direction register into an equal superposition, giving the familiar asymmetric ballistic profile. On a -regular graph the Fourier coin generalises the split across directions, while the Grover coin reflects about the uniform state and is the right choice for spatial search, because search needs amplitude concentrated, not spread. With the Hadamard coin the second moment grows as ; other coins change the constant but never the exponent.

The order of operations matters too. Applying coin then shift (or shift then coin) produces different one-step unitaries, and a walk that applies an extra coin rotation at the start can shift the entire distribution sideways. When you compare two implementations of "the same" walk, check the ordering and the initial coin state first — starting from instead of a real superposition flips the direction the walker drifts.

Continuous-Time Quantum Walks

A CTQW evolves according to the adjacency matrix :

The time evolution is . For the adjacency matrix:

where and are eigenvalues and eigenvectors.

Spatial Search on Graphs

Spatial search uses quantum walks to find a marked vertex:

  1. Prepare uniform superposition
  2. Phase flip the marked vertex
  3. Apply one step of quantum walk
  4. Repeat times

For the complete graph, this matches Grover's query complexity.

Written as a single step, one iteration of spatial search is the product of the walk operator with the phase-flip , applied to the uniform superposition. The phase flip alone does nothing a measurement could see — it only rotates phases — but the subsequent walk converts that phase structure into amplitude concentration on . After iterations on the amplitude on the marked vertex is essentially 1.

The iteration count is where the quadratic win lives. Classically, guessing a marked vertex among costs probes on average; Grover already cuts that to , and a spatial walk reproduces the same bound while touching only local edges. That sounds worse — local moves cannot jump straight to — but interference steers the walker, so locality does not cost asymptotic time on well-connected graphs. It does cost time on poorly connected ones, which is the entire subject of the next section.

Quantum Walk on the Line

For a CTQW on a line, the probability distribution at time is:

where is the th Bessel function. The walker spreads linearly: , compared to for classical walks.

Graph Properties from Walks

Quantum walks can reveal:

  • Gap detection: spectral gap determines mixing time
  • Element distinctness: queries on Johnson graph
  • Triangle finding: queries
  • Graph isomorphism: polynomial speedups for certain classes

Picking a Graph for Spatial Search

Spatial search is not a universal replacement for Grover's oracle, and the deciding variable is how fast the underlying walk mixes. The practical rule: when the classical walk mixes in steps, the quantum walk search reaches ; when mixing slows, search time grows with it, because the walker must physically carry amplitude across the graph.

Graph, verticesClassical mixingQuantum searchVerdict
Complete graph Ideal, matches Grover
Hypercube , Ideal, easy to embed
Cycle relaxationBeats classical , misses
2D grid, Loses a factor
Johnson graph polynomial queriesElement distinctness

The pattern in the last two rows is the one to remember: on a low-dimensional lattice the walker must diffuse through every intermediate vertex, so search inherits a logarithmic penalty that no amount of tuning removes. On a graph with edges that already shortcut across the space — a complete graph, a hypercube, a Johnson graph — locality is free and the walk hits the Grover bound. If your application allows you to choose the interaction graph, choose a well-connected one.

Element Distinctness on the Johnson Graph

The Johnson graph has one vertex per -element subset of an -element universe, with two vertices adjacent when their subsets differ by a single swap. A discrete-time walk on it maintains a working set of elements: at each step it either swaps one element in or out, or applies a step of Grover search inside the current set to look for a duplicate.

Ambainis' algorithm sets and runs for steps, giving the query bound for element distinctness — a proven quadratic improvement over the classical lower bound, though not a full quartic one. The parameter is a genuine trade-off: larger sets make each swap cheaper relative to the search but increase the number of vertices in the graph, and the optimum sits exactly at the balance point above. The same construction with different set sizes yields the known bounds for triangle finding and for evaluating functions that depend on large subsets of their inputs.

Python: Quantum Walk Simulation

python
import numpy as np
import scipy.linalg

def quantum_walk_line(steps=50):
    N = 2 * steps + 1
    center = steps
    A = np.zeros((N, N), dtype=complex)
    for i in range(N-1):
        A[i, i+1] = 1
        A[i+1, i] = 1

    t = steps / 2.0
    U = scipy.linalg.expm(-1j * A * t)
    psi0 = np.zeros(N, dtype=complex)
    psi0[center] = 1.0
    psi_t = U @ psi0
    probs = np.abs(psi_t)**2
    positions = np.arange(N) - center
    mean_sq = np.sum(positions**2 * probs)
    print(f"Spread <x^2> = {mean_sq:.2f}")
    return positions, probs

positions, probs = quantum_walk_line(50)

Python: Discrete-Time Walk with a Coin

The continuous-time version hides the coin. A discrete-time simulation builds the shift on the tensor product of coin and position registers explicitly, which is what you want when you need to change the coin or the initial state:

python
import numpy as np

def coin_rotation(theta):
    c, s = np.cos(theta), np.sin(theta)
    return np.array([[c, s], [s, -c]], dtype=complex)


def dtqw_line(steps=60, theta=np.pi / 4):
    n = 2 * steps + 1
    C = coin_rotation(theta)          # theta = pi/4 reproduces the Hadamard coin
    S = np.zeros((2 * n, 2 * n), dtype=complex)
    for pos in range(n):
        right = min(pos + 1, n - 1)
        left = max(pos - 1, 0)
        S[right, pos] = 1.0            # coin 0 moves right
        S[n + left, n + pos] = 1.0     # coin 1 moves left

    W = S @ np.kron(C, np.eye(n))
    psi = np.zeros(2 * n, dtype=complex)
    psi[steps] = 1.0 / np.sqrt(2)                 # coin 0, centre
    psi[n + steps] = 1j / np.sqrt(2)              # coin 1, centre, phase i

    for _ in range(steps):
        psi = W @ psi

    pos_prob = (np.abs(psi.reshape(2, n)) ** 2).sum(axis=0)
    xs = np.arange(n) - steps
    mean = float(np.sum(xs * pos_prob))
    var = float(np.sum((xs - mean) ** 2 * pos_prob))
    print(f"steps={steps}  mean={mean:.3f}  var={var:.1f}  "
          f"classical var={steps}  ballistic target={steps**2 / 2:.1f}")
    return xs, pos_prob

dtqw_line(60, theta=np.pi / 4)

The printed variance lands near , two orders of magnitude above the classical value of at . Re-running with a biased coin changes the drift and the constant, never the quadratic scaling — that invariance is exactly why walk-based algorithms are robust to implementation detail.

Quantum Walk Complexity

The hitting time of quantum walks:

GraphClassicalQuantum
Complete (KN)O(N)O(sqrtN)
Hypercube (Qn)O(n 2^n)O(n)
Johnson (J(N,k))O(N)O(N^2/3)
Grid (sqrtN times sqrtN)O(N log N)O(N)

Continuous-Time vs Discrete-Time

AspectDiscrete-TimeContinuous-Time
Coin spaceExplicitImplicit
Time evolutionW = S cdot CU(t) = e^-iHt
Graph representationAdjacency + coinHamiltonian
ApplicationsSpatial searchGraph algorithms

Summary

Quantum walks differ from classical walks in one measurable way: amplitude spreads ballistically, , instead of diffusing, . That single fact produces the quadratic speedups on this page. A discrete-time walk is coin plus shift; a continuous-time walk is exponentiation of the adjacency matrix, and the two frameworks simulate each other closely enough that most results translate between them.

Spatial search applies a phase flip to a marked vertex, repeats times, and reaches Grover's bound on graphs that mix classically in steps — complete graphs, hypercubes, Johnson graphs. On a cycle the bound slips to , and on a 2D grid to , because amplitude has to diffuse through a space with no shortcuts. Choosing the graph is therefore part of algorithm design, not background detail.

The same walk machinery powers element distinctness at queries and gives polynomial improvements for triangle finding and certain isomorphism tests.

Common Mistakes

Assuming any quantum walk beats classical search by a square root

Fix: Check the classical mixing time first; slow-mixing graphs such as grids inherit an extra logarithmic factor that cannot be tuned away

Comparing a discrete-time walk with a Hadamard coin against one with a Grover coin and concluding the implementations disagree

Fix: The coin sets the spreading constant and the drift direction; hold the coin and the initial coin state fixed before comparing distributions

Stopping the walk at an arbitrary time and measuring

Fix: Amplitude concentrates periodically; time the evolution against the eigenvalue spacing of the Hamiltonian, or search for the peak in a short scan

Key Takeaways

  • A quantum walk spreads as sigma proportional to t while a classical walk spreads as the square root of t, which is the origin of every quadratic speedup on this page
  • Discrete-time walks need a coin and a shift operator; continuous-time walks exponentiate the adjacency matrix, and the two models largely inter-translate
  • Spatial search reaches O(sqrt N) on graphs that mix classically in O(log N) steps, and degrades to N^(3/4) on a cycle and sqrt(N log N) on a 2D grid
  • Element distinctness uses a walk on the Johnson graph with sets of size N^(2/3) to achieve O(N^(2/3)) queries
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-15

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Quantum Computing Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement