Skip to content

Resource · Guide or article

Knight's Tour

Describes the knight's tour problem, in which a knight visits every square of a board exactly once, and separates open tours from closed ones.

Reviewed

Open the original: Knight's Tour (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open. The knight's tour problem is the mathematical problem of finding a knight's tour. Creating a program to find a knight's tour is a common problem given to computer science students. Variations of the knight's tour problem involve chessboards of different sizes than the usual 8×8, as well as irregular (non-rectangular) boards. The knight's tour problem is an instance of the more general Hamiltonian path problem in graph theory. The problem of finding a closed knight's tour is similarly an instance of the Hamiltonian cycle problem.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • Defines open and closed tours, and mentions non-standard board sizes and shapes
  • Links the problem to Hamiltonian paths and cycles in graph theory
  • Shows animations of an 8x8 tour and a 5x5 open tour

How to use it

PrepKit study advice, not a claim made by the source.

Write a backtracking search for a 5x5 board, print one open tour, and explain how it maps to a Hamiltonian path search.

Scope and limitations

No algorithm, heuristic or complexity is given. The backtracking method is only in the linked GeeksForGeeks article.

Access and format

Short README on GitHub, trekhleb/javascript-algorithms (MIT). English, free.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/uncategorized/knight-tour/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email