Data Structures & AlgorithmsHardGATE CS · ICPC regional

On an 6×6 chessboard, rows and columns are numbered 0 to 5, and squares are written (row, column). A knight moves in the usual L-shape (two squares in one direction and one square across). The knight may not land on the blocked squares (1,0), (2,4), (3,4), (4,2), (5,1), (5,2). It starts at (1,5) and must reach (5,3). What is the minimum number of knight moves needed?

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

Correct answer: D. 4

A BFS that refuses blocked squares gives 4 moves. Ignoring the blocked squares gives 2, and treating the knight like a king gives 4.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic