What is the following code an implementation of?

public class Program {
public static void main(String[] args) {
String text = "ABAACAADAABAAABAA";
String pattern = "AABA";
System.out.println("match found at position: " + search(text, pattern));
}

static int search(String text, String pattern) {
int R = 256;
int[] right = new int[R];

for (int i = 0; i < R; i++ ) {
right[i] = -1;
}
for (int j = 0; j < pattern.length(); j++ ) {
right[pattern.charAt(j)] = j;
}

int m = pattern.length();
int n = text.length();
int skip;

for (int i = 0; i <= n - m; i += skip) {
skip = 0;
for (int j = m-1; j >= 0; j--) {
if (pattern.charAt(j) != text.charAt(i+j)) {
skip = Math.max(1, j - right[text.charAt(i+j)]);
break;
}
}
if (skip == 0) return i;
}
return n;
}
}
a. Boyer-Moore algorithm
b. Naive search algorithm
c. Rabin-Karp algorithm
d. Knuth-Morris-Pratt algorithm


a. Boyer-Moore algorithm

Computer Science & Information Technology

You might also like to view...

A note inserted into the text of a research paper that refers the reader to a source in the bibliography

a. Footnotes b. Citation c. Bibliography

Computer Science & Information Technology

A security policy is a document that defines how an organization deals with some aspect of security

Indicate whether the statement is true or false.

Computer Science & Information Technology

C++ has a special name for the data types istream and ostream. They are called ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

You can move a range by using the cut and paste commands.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology