Data Structures & AlgorithmsHardGATE CS · Product-company placement
What is the edit distance (insert, delete, substitute; each cost 1) between RECESSION and HEAPSORT?
- A. 11
- B. 9
- C. 6
- D. 7
Correct answer: D. 7
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[9][8] = 7.
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
- Symbols occur with frequencies 3, 4, 13, 27, 35. How many bits does an optimal (Huffman) prefix code need for the whole message, and how…
- Keys 12, 16, 26, 38, 48 are searched with frequencies 10, 1, 8, 8, 11 respectively (only successful searches). The cost of a BST is Σ…
- A min-heap holds 31 distinct keys in a 0-indexed array (a full tree with 5 levels). At how many different indices can the 3rd-smallest key…
- In how many ways can a convex polygon with 8 vertices be divided into triangles by non-crossing diagonals?
- In how many different ways can 'pineapplepen' be split into a sequence of words from the dictionary {pine, apple, pen, pineapple…
- The weighted undirected graph A–B (13), A–C (17), B–C (27), B–F (28), C–D (1), C–E (9), C–F (3), E–F (12) has a unique MST. What is the…