|
|
|
These experiments show that:
|
Note:
|
|
|
|
Simplified Boyer-Moore Algorithm:
public static int[] computeLastOcc(String P)
{
int[] lastOcc = new int[128]; // assume ASCII character set
for (int i = 0; i < 128; i++)
{
lastOcc[i] = -1; // initialize all elements to -1
}
for (int i = 0; i < P.length(); i++)
{
lastOcc[P.charAt(i)] = i; // The LAST value will be store
}
return lastOcc;
}
|
public static int[] computeLastOcc(String P)
{
int[] lastOcc = new int[128]; // assume ASCII character set
for (int i = 0; i < 128; i++)
{
lastOcc[i] = -1; // initialize all elements to -1
}
for (int i = 0; i < P.length()-1; i++) // Don't use the last char
// to compute lastOcc[]
{
lastOcc[P.charAt(i)] = i; // The LAST value will be store
}
return lastOcc;
}
|
How to run the program:
|