Page 193 - Algorithms Notes for Professionals
P. 193

}
                else // if (len == 0)
                {
                  lps[i] = 0;
                  i++;
                }
              }
           }
       }

       // Driver program to test above function
       int main()
       {
          char *txt = "ABABDABACDABABCABAB";
          char *pat = "ABABCABAB";
          KMPSearch(pat, txt);
          return 0;
       }

       Output:


       Found pattern at index 10






























































       colegiohispanomexicano.net – Algorithms Notes                                                           189
   188   189   190   191   192   193   194   195   196   197   198