Topic-1 - Naive String Matching Algorithm
Topic-1 - Naive String Matching Algorithm
Analysis: This for loop from 3 to 5 executes for n-m + 1(we need at least m characters at the end)
times and in iteration we are doing m comparisons. So the total complexity is O (n-m+1).
Example:
Suppose T = 1011101110
P = 111
Find all the Valid Shift
Solution:
https://www.javatpoint.com/daa-naive-string-matching-algorithm 2/8
26/12/2022, 09:44 DAA Naive String Matching Algorithm - javatpoint
https://www.javatpoint.com/daa-naive-string-matching-algorithm 3/8