Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2
Strings a = "bccbc" and b = "bbacaa". 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. 5
- B. 6
- C. 4
- D. 1
Correct answer: C. 4
The DP table gives 4. The insertion–deletion distance (no substitution) gives 5, 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
- Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→C (9)…
- Undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–C (2), A–D (1), B–C (2), B–D (2), C–D (1). How many distinct…
- Keys [2, 42, 28, 49, 8, 35] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right, left–right…
- Distinct words ['a', 'cbb', 'c', 'b'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a root)…
- Directed weighted graph on vertices A, B, C, D, E with edges listed in this exact order: A→B (6); E→A (4); C→D (5); B→E (5); B→C (4); A→D…
- Distinct words ['ca', 'b', 'bac', 'a', 'c', 'bbbb'] are inserted into an empty trie (one node per character, shared prefixes sharing…