Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Strings a = "acbc" and b = "aabc". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein distance). What is the edit distance between a and b?
- A. 2
- B. 4
- C. 1
- D. 0
Correct answer: C. 1
The DP table gives 1. The insertion–deletion distance (no substitution) gives 2, which overcounts substitutions.
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
- Keys [30, 27, 11, 18, 49, 38, 37] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right…
- Array [22, 29, 23, 18, 14, 20, 10] is turned into a min-heap in place with bottom-up heapify: for i from ⌊n/2⌋−1 down to 0, sift the…
- Union–find on elements 0 to 7, all starting as singletons, with no path compression. union(x, y): let rx, ry be the roots of x and y; if…
- Directed weighted graph on vertices A, B, C, D, E with edges (u→v, w): A→D (3); E→D (4); A→E (3); C→A (8); A→C (5); D→C (6); E→C (9); B→E…
- Distinct keys [26, 13, 5, 17, 19, 4] are inserted, in the order given by the sequence [19, 13, 4, 5, 17, 26], into an empty binary search…
- Undirected simple graph on vertices A, B, C, D, E, F with edges A–C (1), A–D (1), A–F (1), B–D (1), B–E (1), D–E (1), E–F (1) (weights…