Data Structures & AlgorithmsHardGATE CS
Edit distance between MARTIAN and COMPILER where insert and delete cost 1 each but a substitution costs 2: what is the minimum total cost?
- A. 7
- B. 11
- C. 13
- D. 12
Correct answer: B. 11
With substitution = 2 it is never cheaper than delete + insert, so the cost is |a| + |b| − 2·LCS = 7 + 8 − 2·2 = 11. The unit-cost edit distance (7) is the trap.
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
- Dijkstra's algorithm runs from A on the directed graph A→C (4), B→A (1), B→F (6), C→B (7), C→E (12), C→F (6), D→C (3), E→A (15), E→B (3)…
- The weighted undirected graph A–B (27), A–D (3), A–E (1), B–C (25), B–D (8), B–E (18), B–F (5), C–E (9) has a unique MST. What is the…
- A simple undirected graph has 13 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- What is the length of the shortest string that has BOTH COMPILER and SHORTEST as subsequences (shortest common supersequence)?
- Prim's algorithm starts at G on the weighted undirected graph A–B (19), A–F (12), A–G (21), B–C (13), B–D (23), B–E (6), B–G (29), D–E…
- The weighted undirected graph A–B (1), A–C (6), A–D (3), A–E (4), B–C (4), B–D (3), C–D (5) has repeated weights. How many different…