1.

What is the worst case time complexity of KMP algorithm for pattern searching (m = length of text, n = length of pattern)?(a) O(n)(b) O(n*m)(c) O(m)(d) O(log n)I had been asked this question during an online exam.This interesting question is from Searching topic in section Searching of Data Structures & Algorithms II

Answer»

Correct CHOICE is (c) O(m)

The EXPLANATION is: KMP algorithm is an efficient pattern searching algorithm. It has a time complexity of O(m) where m is the LENGTH of text.



Discussion

No Comment Found

Related InterviewSolutions