liveBook · Manning

Permutation

As explained in Quantum Programming in Depth

A permutation is an arrangement containing each member of a finite set exactly once.

A permutation arranges every member of a finite set exactly once. In the N queens search, valid inputs are permutations of the integers from 0 through N−1, encoding one distinct column position for each row. section 8.3.1

Reducing the N queens search space

Encoding each row by its queen’s column initially gives N^N possible inputs. Restricting inputs to permutations removes repeated columns, reducing the space to N!. For N = 4, the space falls from 256 to 24 and the optimal Grover iteration count from 9 to 3, although preparing the equal superposition becomes harder. section 8.3.1

Figure 8.7 The new input encoding relies on the fact that only inputs in which each row has exactly one queen can be solutions to the puzzle. We represent each row of the board as just one integer, the column index of the queen in that row.
figure

Use the board encoding to see how one integer per row represents a candidate permutation and avoids multiple queens in one row. section 8.3.1

How Quantum Programming in Depth covers it

How deep it goes
Contrasts N^N with N!, quantifies the N = 4 improvement, and notes the harder state preparation without deriving its circuit.
Examples
Uses column-index encodings for N queens and compares the four-queen spaces of 256 unrestricted inputs and 24 permutations.
What you can do after
Evaluate/understand how permutation-based encodings reduce Grover iterations while complicating equal-superposition preparation.
How it connects
Connects permutations with the N queens puzzle, Grover's algorithm, equal superposition, oracle design, and search-space encoding.

Also explained in

Compare how 9 books explain permutation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantum Programming in Depth. The section links point to the parts of the book it draws on.