McqMate

Q. |
## 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) |

Answer» C. o(m) | |

Explanation: kmp algorithm is an efficient pattern searching algorithm. it has a time complexity of o(m) where m is the length of text. |

1.2k

1

Do you find this helpful?

8

View all MCQs in

Design and Analysis of Algorithms
M

2 years ago

It is O(m+n) actually. Here is a nice little explanation https://www.w3spot.com/2020/07/kmp-algorithm-explained-in-plain-english.html

0

- Rabin Karp algorithm and naive pattern searching algorithm have the same worst case time complexity.
- What is the time complexity of Z algorithm for pattern searching (m = length of text, n = length of pattern)?
- What is the auxiliary space complexity of Z algorithm for pattern searching (m = length of text, n = length of pattern)?
- Worst case is the worst case time complexity of Prim’s algorithm if adjacency matrix is used?
- What is the worst case time complexity of a quick sort algorithm?
- The naive pattern searching algorithm is an in place algorithm.
- What is the worst case time complexity of dynamic programming solution of set partition problem(sum=sum of set elements)?
- What is the worst case complexity of quick hull?
- Is Coppersmith-Winograd algorithm better than Strassen’s algorithm in terms of time complexity?
- What is the time complexity of the brute force algorithm used to find the length of the longest palindromic subsequence?