Data Structures & AlgorithmsModerateGATE CS · ICPC regional

On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (4, 5) and must reach (6, 1) (as (row, column)). A knight move is the usual L shape (two in one direction and one perpendicular), and all squares are available. What is the minimum number of knight moves?

  1. A. 6
  2. B. 3
  3. C. 2
  4. D. 4

Correct answer: C. 2

A BFS over knight moves gives 2; the Chebyshev or Manhattan distance ignores the L-shape, which is why both are wrong.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic