Data Structures & AlgorithmsHardProduct-company MCQ pattern
What is the edit distance (insert, delete, replace, each cost 1) between FLASK and FLOSSY?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
Keep F L; replace A → O; keep S; replace K → S; insert Y: 3 operations, and the DP table confirms no 2-step way exists because the lengths differ by 1 and two letters also differ. Counting a replace as delete + insert gives 5.
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
- In how many ways can 10 be made from coins of 2, 3 and 5 (unlimited supply, order does not matter)?
- 0/1 knapsack, capacity 7. Items (weight, value): (1, 1), (3, 4), (4, 5), (5, 7). What is the maximum total value?
- Matrices A (10 × 20), B (20 × 30) and C (30 × 40) are to be multiplied. What is the minimum number of scalar multiplications?
- What is the length of the longest strictly increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7]?
- AVL tree: keys 30, 10, 20 are inserted in that order into an empty tree. What rebalancing happens, and what is the root afterwards?
- What is the minimum number of nodes in an AVL tree of height 4 (a single node has height 0)?