Data Structures & AlgorithmsHardGATE CS · ICPC regional
Using unit-cost insertions, deletions and substitutions, what is the minimum number of operations needed to turn the string 'ccbbcbb' into 'cbaacca'?
- A. 8
- B. 5
- C. 3
- D. 4
Correct answer: B. 5
This is the Levenshtein (edit) distance, computed by the standard DP. A substitution costs one operation, so the insert-and-delete-only distance n + m − 2·LCS is larger whenever a substitution helps.
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
- Coins of denominations [2, 12, 13, 21] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 48?
- Coins of denominations [2, 3, 15, 21] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 33?
- Coins of denominations [2, 9, 21] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 57?
- Coins of denominations [2, 9, 12] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 32?
- Coins of denominations [2, 10, 17] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 50?
- Coins of denominations [2, 7, 11, 13] are available in unlimited supply. What is the minimum number of coins needed to pay exactly 58?