Data Structures & AlgorithmsModerateGATE CS · ICPC regional
On an 8 × 8 chessboard with rows and columns numbered 0 to 7, a knight starts at (5, 7) and must reach (0, 5) (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?
- A. 7
- B. 3
- C. 5
- D. 4
Correct answer: B. 3
A BFS over knight moves gives 3; the Chebyshev or Manhattan distance ignores the L-shape, which is why both are wrong.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Undirected weighted graph on vertices A, B, C, D, E, F with edges A–B (6), A–E (6), A–F (7), B–C (3), B–D (6), B–F (9), C–E (8), D–F (5)…
- Words ['dd', 'da', 'bb', 'bd', 'db', 'cc', 'aba'] (each may be used at most once). A chain is a sequence of these words in which the first…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–D (2), A–E (1), B–C (2), C–D (1), C–E (3), D–E (2). An edge is CRITICAL…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (1), A–D (2), B–C (1), B–D (6), B–E (3), C–E (1). Among all…
- Directed weighted graph on vertices A, B, C, D, E with edges listed in this exact order: D→A (3); B→A (2); E→A (-3); A→B (3); D→E (4); A→D…
- Keys are inserted in the order 32 20 62 89 57 42 59 into an empty binary search tree. Then the key 32 (which has two children) is deleted…