Data Structures & AlgorithmsHardGATE CS
What is the edit distance (insert, delete, substitute; each cost 1) between MATRIX and STRATEGY?
- A. 10
- B. 7
- C. 6
- D. 5
Correct answer: C. 6
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[6][8] = 6.
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
- A B-tree has minimum degree t = 3 (every non-root node has between 2 and 5 keys) and height 3 (a root-only tree has height 0). What are…
- How many subsets of {1, 4, 8, 9, 10, 11, 12} have sum exactly 27?
- What is the maximum flow from S to T in the network with directed capacities A→B (15), A→C (9), A→T (12), B→T (12), C→B (12), S→A (6), S→B…
- An undirected graph has edges A–B, A–D, B–H, C–D, C–F, C–G, D–G, E–F, E–H, F–G. BFS starts at A and always scans neighbours in…
- A binary tree with distinct labels has INORDER G D C I F A B H E and LEVEL-ORDER E A D H G I B C F. What is its postorder traversal?
- An undirected graph has edges A–D, B–D, B–F, C–D, C–E, D–G, E–F, E–H, F–G, G–H. BFS starts at A and always scans neighbours in…