Data Structures & AlgorithmsHardGATE CS
Edit distance between PARAGRAPH and BINARY where insert and delete cost 1 each but a substitution costs 2: what is the minimum total cost?
- A. 7
- B. 13
- C. 12
- D. 11
Correct answer: D. 11
With substitution = 2 it is never cheaper than delete + insert, so the cost is |a| + |b| − 2·LCS = 9 + 6 − 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
- Bellman–Ford runs from A on the directed graph whose edges are relaxed in EVERY pass in this fixed order: D→B (4), F→D (8), D→C (2), A→E…
- A B-tree has minimum degree t = 4 (every non-root node has between 3 and 7 keys) and height 2 (a root-only tree has height 0). What are…
- The weighted undirected graph A–B (6), A–D (16), A–E (19), A–F (12), B–E (1), B–F (2), C–D (26), C–E (14) has a unique MST. What is the…
- Kruskal's algorithm runs on the weighted undirected graph A–B (20), A–C (3), A–E (8), A–F (6), B–D (10), C–D (1), C–G (16), D–E (25), D–F…
- A binary search tree holds exactly the keys 16, 17, 41, 44, 69, 81, 82, 95. Which ONE of the following sequences can be its PREORDER…
- In the DAG with edges A→D, A→F, C→B, D→B, D→C, D→E, D→F, D→G, E→B, G→E, G→F, how many distinct directed paths are there from A to F, and…