Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
A grid has 4 rows and 4 columns with these values (top to bottom): 9446 8699 5398 3165 A path moves between side-adjacent cells (up, down, left or right) and each next cell must have a strictly larger value than the current cell. What is the largest number of cells on such a path?
- A. 3
- B. 5
- C. 6
- D. 4
Correct answer: B. 5
A memoised DFS from every start gives 5 cells. Restricting moves to right and down gives 3, and allowing equal values (non-decreasing paths) gives 4.
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
- Floyd–Warshall runs on vertices 1 to 5 with these arcs u→v (weight): 1→2 (4), 1→3 (2), 2→1 (11), 3→1 (8), 3→2 (4), 3→4 (7), 3→5 (4), 4→1…
- Bellman–Ford is run from source U on the directed graph whose arcs (weights in brackets) are listed in the order they are relaxed: K→U…
- A four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…
- A tree has vertices with weights in brackets: D[15], C[15], R[7], L[9], S[1], Z[3], B[13], H[13], F[6]. The edges are D–C, D–R, R–L, D–S…
- A tree on the vertices C, F, H, L, P, V, W has the arcs V→P, F→P, P→C, F→H, V→L, W→H (each undirected edge is directed as shown). You may…
- Each cell of a grid with 3 rows and 4 columns has an arrow: R = right, L = left, U = up, D = down. RRLL URUU RRUD From a cell you may move…