Created
July 12, 2020 13:54
-
-
Save codertcet111/def2ce59b95343364162751b74be68e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Naive (T[0....n], P[0.....m]) | |
{ | |
//This function is to find pattern P in the string T | |
//Inputs are the two string T and P | |
//Output will be the index of the matched position of T string | |
for (i = 0, j = 0; to i <= n - m) do | |
{ | |
if (T[i] == P[j]){ | |
temp_i = i | |
while(pattern P matching with Text){ | |
i++; | |
j++; | |
if j reaches m-1{ | |
pattern matched, return the 'i - m' value as the starting of the matched index in T string | |
{ | |
} come out of while loop, no match occurs | |
Now set i = temp_i + 1, j = 0 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment