Data Structures & AlgorithmsVery hardICPC regional · GATE CS top band
2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as _). Current board: 4 1 _ / 2 5 3. Goal board: 1 2 3 / 4 5 _. A move slides a tile that is orthogonally adjacent to the blank into the blank. What is the minimum number of moves to reach the goal?
- A. 4
- B. 7
- C. 9
- D. 5
Correct answer: B. 7
A BFS over all 360 reachable boards from the goal gives 7. Counting misplaced tiles or summing Manhattan distances are lower-bound heuristics, not the exact answer.
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 with edges A–B (1), A–C (2), A–E (2), B–C (2), C–D (1), C–E (3). How many distinct…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (3), A–C (3), B–C (3), B–D (3), C–D (1), C–E (4). Among all…
- Connected undirected graph on vertices A, B, C, D, E, F, G, H with edges A–D (1), A–E (1), B–D (1), B–E (1), B–G (1), C–D (1), C–H (1)…
- A binary tree with distinct letters has preorder FBGCHAED and inorder GHACBDEF. What is its postorder traversal (left, right, root)…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (15), A–C (13), A–D (20), B–D (20), B–E (17), C–D (4), C–E…
- Directed weighted graph on vertices A, B, C, D, E with edges (u→v, w): B→D (1); C→D (7); B→A (4); B→C (1); D→E (7); A→D (7); D→C (3). Let…