Consider the following string matching algorithm, what is the name of this algorithm?
void algo(String P, String T) {
int N = T.length()-1;
int M = P.length()-1;
char p = P.charAt(M);
for(int x=N;x>=0;x--){
if(T.charAt(x) == p){
int y=0;
for(y=0;y<=M;y++){
if(T.charAt(x-M+y) != P.charAt(y))
break;
}
if(y ==M+1)
System.out.printf("Match at:%d%n",(x-M));
}
}
}
a. Naïve string matching
b. Boyer-Moore
c. Rabin-Karp
d. Aho-Corasick
a. Naïve string matching
This is the naive string match algorithm, but in reverse, that is, from the end of the string. When a match at the last character of the pattern P is found at the tail of the string text T, a match is reported. To compare the pattern P to the string text T at the position, the comparison is offset to compare from the start of the pattern P.
You might also like to view...
User exceptions are differentiated in a restricted document by:
A) color. B) font type. C) comment box style. D) font size.
How does a cross-site request forgery (XSRF) attack work?
What will be an ideal response?
The_________attribute is always needed in aninputelement while submitting the form to a server.?
Fill in the blank(s) with the appropriate word(s).
The term ____________________ is used to describe an electronic device, operating under the control of instructions stored in its own memory, that can accept data, process the data according to specified rules, produce results, and store the results for future use.
Fill in the blank(s) with the appropriate word(s).