What is the following code an implementation of?
public class Program {
public static void main(String[] args) {
String text = "AABAACAADAABAAABAA";
String pattern = "AABA";
search(text, pattern);
}
private static void search(String text, String pattern) {
int M = pattern.length();
int N = text.length();
for (int i = 0; i <= N - M; i++) {
int j;
for (j = 0; j < M; j++) {
if (text.charAt(i + j) != pattern.charAt(j)) {
break;
}
}
if (j == M) {
System.out.println("Pattern found at index " + j);
}
}
}
}
a. Naive search algorithm
b. Boyer-Moore algorithm
c. Knuth-Morris-Pratt algorithm
d. Rabin-Karp algorithm
a. Naive search algorithm
You might also like to view...
Which of the following is NOT a method that can be used to execute an Integration Services package?
A. dtexec.exe B. dtexecui.exe C. SQL Server Agent job D. Windows task scheduler
What does the .. entry in a directory point to? What does this entry point to in the root (/) directory?
What will be an ideal response?
A photo's color intensity can be modified by changing the brightness and content.
Answer the following statement true (T) or false (F)
When using subtotal, what does the 4th button of the outline levels do?
A) Displays subtotals by the main subtotal category, the secondary subtotal category, and the grand total B) Displays subtotals by the main subtotal category and the grand total C) Displays the entire list D) Collapses the outline to display the grand total only