GATE Computer ScienceHardGATE CS (PYQ pattern)
The edit distance between PNEUMONIA and AMMONIA is computed with insertion, deletion and substitution each costing 1. What is the minimum cost?
- A. 6
- B. 2
- C. 4
- D. 5
Correct answer: C. 4
The common suffix MONIA costs nothing, and PNEU → AM costs 4 (substitute P→A and N→M, delete E and U); the Levenshtein table confirms no cheaper script exists, giving 4. 6 = 9 + 7 − 2·LCS(=5) is the cost when substitution is not allowed (or costs 2); 2 is just the length difference.
More Algorithms questions
- Matrices A₁ … A₇ have dimensions 5×12, 12×7, 7×20, 20×4, 4×15, 15×9 and 9×6, i.e. the dimension array p = [5, 12, 7, 20, 4, 15, 9, 6]…
- A recursive matrix-chain function without memoisation, cost(i, j), returns 0 when i = j and otherwise calls cost(i, k) and cost(k+1, j)…
- A 0/1 knapsack has capacity 26 and items (weight, value): (12, 24), (7, 13), (11, 23), (8, 15), (9, 16), (6, 11). The maximum total value…
- A coin system has denominations {1, 5, 10, 20, 25}. The greedy algorithm (always take the largest coin that fits) first gives a…
- For the coin system {1, 5, 12, 25}, among the amounts 1, 2, …, 100, for how many amounts does the greedy algorithm use more coins than the…
- Using unlimited coins of denominations 2, 5, 7 and 10 (order does not matter), how many ways are there to pay exactly 40 using at most 6…