|    
			
				13/02/2012, 17:24
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: febrero-2012 Ubicación: Zacatecas 
						Mensajes: 1
					 Antigüedad: 13 años, 8 meses Puntos: 0 |  | 
  |  Respuesta: Backward Oracle Matching Java  
  Chuy Benitez, nadie te ayudo!! jaja, weno, esta es una traduccion que hice en su momento de un Codigo hecho en Cpublic class Bom{
 private final char TRUE = (char) 1;
 private final int UNDEFINED = -1;
 void Bom(String patron, String texto){
 int i, j, p, period = 0, q, shift;
 int m = patron.length();
 int n = texto.length();
 char y[] = texto.toCharArray();
 char T[] = new char[m + 1];
 List L[] = new List[m + 1];
 oracle(patron,T,L);
 
 j = 0;
 while (j <= n - m) {
 i = m - 1;
 p = m;
 shift = m;
 while (i + j >= 0 &&
 (q = getTransition(patron, p, L, y[i + j])) != UNDEFINED) {
 p = q;
 if (T[p] == TRUE) {
 period = shift;
 shift = i;
 }
 i--;
 }
 if (i < 0) {
 System.out.println("Encontrado en: " + j);
 shift = period;
 }
 j += shift;
 }
 }
 void oracle(String patron, char T[], List L[]){
 int i, p, q = 0, m = patron.length();
 int S[]= new int[m+1];
 char c;
 S[m] = m + 1;
 for (i = m; i > 0; --i){
 c = patron.charAt(i -1);
 p = S[i];
 while (p <= m &&
 (q = getTransition(patron, p, L, c)) == UNDEFINED){
 
 setTransition(p, i - 1, L);
 p = S[p];
 }
 S[i - 1] = (p == m + 1 ? m: q);
 }
 p = 0;
 while (p <= m) {
 T[p] = TRUE;
 p = S[p];
 }
 }
 int getTransition(String patron, int p, List L[], char c){
 List cell;
 char x[] = patron.toCharArray();
 if (p > 0 && x[p -1] == c){
 return (p - 1);
 }
 else{
 cell = L[p];
 while (cell != null) {
 if (x[cell.element] == c) {
 return (cell.element);
 }
 else {
 cell = cell.next;
 }
 }
 return UNDEFINED;
 }
 }
 void setTransition(int p, int q, List L[]){
 List cell = new List();
 cell.element = q;
 cell.next = L[p];
 L[p] = cell;
 }
 public static void main(String args[]) {
 Bom busqueda = new Bom();
 busqueda.Bom("Java", "Java apesta, y Java es una isla de Indonesia, ironico que aun traduzca para Java");
 }
 }
 public class List {
 int element=0;
 List next;
 }
     |