Data Structures & AlgorithmsModerateICPC regional · GATE CS top band
4 × 4 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. 14
- B. 5
- C. 6
- D. 16
Correct answer: B. 5
Counting right/down paths with DP gives 5; 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
- Words ['bcb', 'c', 'ac', 'abbb', 'c', 'bac', 'bbb'] are inserted in this order into an empty trie with one node per character, shared…
- Array A = [3, 11, 10, 2, 3, 8, 6]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the…
- Connected undirected weighted graph on vertices A, B, C, D, E, F with edges A–B (9), A–C (8), A–D (9), A–E (19), B–D (3), B–E (8), B–F…
- Consider the recursive function def f(n): if n < 2: return n; return f(n-1) + f(n-2). Evaluate f(9) and count every invocation of f…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (2), A–C (1), A–E (3), B–E (2), C–D (1), C–E (3), D–E (2). An edge is…
- Words ['bbb', 'b', 'aab', 'baa', 'baa', 'cc'] are inserted in this order into an empty trie with one node per character, shared prefixes…