Question

The Knuth-Morris-Pratt (KM

  • P algorithm improves upon the Naive approach by avoiding unnecessary re-comparisons. It achieves this by:
A Using a hash function.
B Preprocessing the text to build a suffix tree.
C Preprocessing the pattern to build a "longest proper prefix which is also suffix" (LPS) array.
D Always shifting the pattern by 'M' positions.
E Comparing characters from right to left.
Practice Next

Hey! Ask a query