Data Structures & AlgorithmsModerateTCS NQT · string DP
Problem: What is the time complexity of the Wagner-Fischer dynamic programme for edit distance on strings of length n and m?
- A. O(n + m)
- B. O(2^{n+m})
- C. O(nm)
- D. O(n log m)
Correct answer: C. O(nm)
Each of the n*m cells is filled in constant time from three neighbours.
More Coding Interview Problems questions
- Problem: Which two properties define a matroid, which is what makes the greedy algorithm optimal?
- Problem: Which algorithm finds shortest paths in a grid where each cell weight is 0 or 1?
- Problem: Which technique counts subarrays with sum at most K in a non-negative array in O(n)?
- Problem: What is the time complexity of subset-sum over n items with a bitset of width W (up to 10^5)?
- Problem: What is the purpose of the low-link value in Tarjan's strongly connected components algorithm?
- Problem: What is the worst-case complexity of the SPFA (queue-based Bellman-Ford) shortest path algorithm?