// // Motif.java // RechercheMotif // // Created by Jean-Michel Couvreur on Tue Apr 05 2005. // Copyright (c) 2005 __MyCompanyName__. All rights reserved. // import java.util.*; public class Motif { static int recherche1(String text, String motif) { return naif1(text,motif); } static List recherche2(String text, String motif) { return naif2(text,motif); } static int recherche3(String text, String motif, int debut) { return naif3(text,motif,debut); } static int recherche4(String text, String motif, int debut) { return automate(text,motif,debut); } static int recherche5(String text, String motif, int debut) { return algoKMP(text,motif,debut); } static int naif1(String text, String motif) { int res = 0; int n = text.length(); int m = motif.length(); for (int i=0; i<=n-m; i++) { int j = 0; while (j 0 int k = Math.min(m, q+1); while ((k>0) && !suffixe(motif, k, q, motif.charAt(i))){ k = k-1; } res.put(new Clef(q,motif.charAt(i)),new Integer(k)); } } return res; } static boolean suffixe(String motif, int k, int q, char c){ boolean res = true; for (int i=0; i