GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Balloons with numbers [3, 1, 5, 8, 2, 6] are burst one at a time. Bursting a balloon with neighbours l and r (a missing neighbour counts as 1) earns l × value × r, and then the neighbours become adjacent. What is the maximum total number of coins?
- A. 432
- B. 465
- C. 480
- D. 508
Correct answer: B. 465
Think of the last balloon burst in each interval: dp[i][j] = max over k of dp[i][k] + dp[k][j] + a[i]·a[k]·a[j] with sentinels 1 at both ends. This gives 465 for this input (checked by running the DP).
More Algorithms questions
- A directed graph has edges A→B 3, B→C −2, C→D 4, A→C 6, A→D 12, D→E 1, C→E 7, B→E 9. What is the length of the shortest walk from A to E…
- Borůvka's algorithm is run on the graph with edges (weights) 0-1 (7), 0-3 (5), 1-2 (8), 1-3 (9), 1-4 (10), 2-4 (6), 3-4 (15), 3-5 (11)…
- A weighted undirected graph on vertices 0–6 has edges (weight) 0-1 7, 0-3 5, 1-2 8, 1-3 9, 1-4 10, 2-4 6, 3-4 15, 3-5 11, 4-5 12, 4-6 13…
- How many satisfying assignments does the formula (x₁ ∨ x₂) ∧ (¬x₁ ∨ x₃) ∧ (¬x₂ ∨ ¬x₃) ∧ (x₂ ∨ x₄) ∧ (¬x₄ ∨ x₃) ∧ (x₁ ∨ ¬x₄) have over the…
- A topological order of the DAG with edges A→B, A→C, B→D, C→D, C→E, D→F, E→F, E→G, G→F, H→C, H→G is produced by running DFS (roots in…
- A directed graph has edges s→a, s→b, s→c, s→d, a→m, b→m, c→m, m→p, m→q, m→r, p→t, q→t, r→t, d→t. Let E be the maximum number of…