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 patternHash = pattern.hashCode();
int M = pattern.length();
int N = text.length();
for (int i = 0; i <= N - M; i++) {
String part = text.substring(i, i + M);
if (part.hashCode() == patternHash && part.equals(pattern)) {
System.out.println("Pattern found at index " + i);
}
}
}
}
a. Rabin-Karp algorithm
b. Naive search algorithm
c. Boyer-Moore algorithm
d. Knuth-Morris-Pratt algorithm
a. Rabin-Karp algorithm
You might also like to view...
What is the output of the following program segment?
``` Dim temp() As String = IO.File.ReadAllLines('Data.txt") Dim n As Integer = temp.Count - 1 Dim numbers(n) As Double, h As Double = 0 For i As Integer = 0 To n numbers(i) = CDbl(temp(i)) Next For k As Integer = 0 to n h += numbers(k) Next txtBox.Text = CStr(h) ``` Assume the four rows of the file Data.txt contain the following entries: 2, 4, 2, 3 (A) 11 (B) 2 (C) 7 (D) 4
Documents written in MathML and CML are ____ documents.
A. XHTML B. HTML C. XSL D. XML
When every device on the Ethernet LAN receives data from one device, it is called ____.
A. spraying B. transmitting C. broadcasting D. delivering
Cloud computing uses server virtualization.
Answer the following statement true (T) or false (F)