Data Structures & AlgorithmsModerateICPC regional · string round
Problem: What is the time complexity of computing the KMP prefix function of a pattern of length m?
- A. O(m^2)
- B. O(m log m)
- C. O(m)
- D. O(2^m)
Correct answer: C. O(m)
Amortised pointer movement along the failure chain is bounded by the number of characters processed.
More Coding Interview Problems questions
- Problem: Which structure supports push, pop and getting the minimum, all in O(1) amortised time?
- Problem: Which property makes counting sort stable and therefore usable inside radix sort?
- Problem: Which structure gives a queue with O(1) amortised enqueue, dequeue and minimum queries?
- Problem: The Chinese remainder theorem gives a unique solution modulo M for a system of congruences under which condition?
- Problem: What guarantee does the maximal-matching heuristic give for vertex cover?
- Problem: Which problem is the standard application of the monotonic deque?