Data Structures & AlgorithmsModerateGATE CS · ICPC regional
4 × 5 grid, rows top to bottom ('#' = blocked, '.' = open): ..#.. / ..#.. / ..... / ...#.. Count the paths from top-left to bottom-right that move only RIGHT or DOWN and never enter a blocked cell. How many such paths exist?
- A. 3
- B. 17
- C. 20
- D. 4
Correct answer: A. 3
Counting right/down paths with DP gives 3; blocked cells contribute zero paths. Counting open cells instead of paths is a confusion of the two.
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
- Complete undirected graph on vertices A to F with symmetric edge weights given row by row (row i, column j = weight of edge between…
- On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (0, 3) and must reach (5, 2) (as (row, column)). A knight…
- Distinct keys [27, 2, 19, 11, 24, 4] are inserted, in the order given by the sequence [24, 11, 4, 19, 2, 27], into an empty binary search…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (2), A–D (2), A–E (1), B–D (3), B–E (2), C–E (1). An edge is CRITICAL…
- Distinct words ['aac', 'cb', 'ba', 'bc', 'a'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a…
- Undirected weighted graph on vertices A, B, C, D, E, F; its edges, in this listed order, are: C–F (2), B–D (2), D–E (7), B–C (9), D–F (2)…