1. Home
  2. Computer Science MCQs
  3. Algorithms and Data Structures
  4. Which data structure provides efficient string matching…

Added 12 Sep 2025

Which data structure provides efficient string matching with O(m) preprocessing and O(n) search time?

  1. Naive String Matching
  2. Knuth-Morris-Pratt Algorithm Correct answer
  3. Rabin-Karp Algorithm
  4. Boyer-Moore Algorithm

Correct answer

B. Knuth-Morris-Pratt Algorithm

16 views

MCQSEXAM

Explanation

The Knuth-Morris-Pratt algorithm provides efficient string matching with linear time complexity.

Reference

Asked in: GATE CS, UGC NET CS

https://www.geeksforgeeks.org/kmp-algorithm-for-pattern-searching/

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Algorithms and Data Structures MCQs

Practise all Algorithms and Data Structures MCQs

Similar MCQs