The naive pattern matching algorithm may become inefficient for large texts or patterns due to its _______ time complexity.

  • O(1)
  • O(log n)
  • O(n)
  • O(n^2)
The naive pattern matching algorithm may become inefficient for large texts or patterns due to its quadratic (O(n^2)) time complexity. This is because, in the worst case, the algorithm checks all possible alignments of the pattern with the text, leading to a time-consuming process for large inputs.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *