Data Structures & AlgorithmsHardGATE CS · Product-company placement
What is the edit distance (insert, delete, substitute; each cost 1) between SUBSEQUENT and PLATFORM?
- A. 16
- B. 12
- C. 10
- D. 9
Correct answer: C. 10
Fill the (|a|+1) × (|b|+1) table with D[i][j] = min(D[i−1][j] + 1, D[i][j−1] + 1, D[i−1][j−1] + [aᵢ ≠ bⱼ]); D[10][8] = 10.
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→B (4), A→F (8), B→C (1), B→D (10), C→A (3), C→D (8), C→E (6), C→F (6), E→B (1)…
- In the DAG with edges A→E, A→G, B→E, C→A, C→B, C→E, C→F, C→G, D→F, E→F, G→F, how many distinct directed paths are there from C to F, and…
- For the string PROPERTY, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?
- DFS runs on the directed graph with adjacency lists A: D; B: CF; C: AEG; D: –; E: ABG; F: D; G: F, starting at A, scanning lists in the…
- Symbols occur with frequencies 24, 26, 33, 34, 35, 38. How many bits does an optimal (Huffman) prefix code need for the whole message, and…
- A binary search tree holds exactly the keys 27, 34, 63, 64, 72, 73, 95, 99. Which ONE of the following can be its POSTORDER traversal?