Data Structures & AlgorithmsModerateICPC regional · GATE CS top band
On an 6 × 6 chessboard with rows and columns numbered 0 to 5, a knight starts at (3, 5) and must reach (5, 0) (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
- Dictionary D = {bem, cle, gcc, icd, imb, lbg, lcp, lri, ois, opg, scc, scp} (all words have 3 letters). Starting from the word 'lcd', a…
- Directed weighted graph on vertices A, B, C, D, E with edges E→C (-3); A→D (-4); A→B (-2); D→B (0); B→C (-2); A→E (-1); E→D (0); B→E (-4)…
- Array A = [5, 6, 5, 4, 3, 8, 4, 6] (indices 0 to 7). Count the non-empty subsets of positions (each position used at most once, subsets…
- 2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as ). Current board: 2 4 / 1 5 3. Goal board: 1 2 3 / 4 5 . A move slides a…
- Connected undirected graph on vertices A, B, C, D, E, F with edges A–C (1), A–F (1), B–D (1), C–D (1), C–F (1), D–E (1), D–F (1) (weights…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (2), A–C (1), A–D (3), A–E (1), B–C (2), B–D (2), C–D (2). An edge is…