skip to main | skip to sidebar

Computers and Computer Science Searching

8 Eylül 2007 Cumartesi

Brute force string searching

#include 
int bfFind(int n, char *txt, int m, char *pat)
{
int i, j, k, lim;
int nmatch = 0;
lim = n - m + 1;
i = 0;
while (i < lim) {
k = i;
for (j = 0; j < m && txt[k] == pat[j]; j++)
k++;
if (j == m) {
nmatch++;
printf("%d \n", i);
i += m;
}
else
i++;
}
return(nmatch);
}
/* End of File */
Gönderen pasta zaman: 08:28

Hiç yorum yok:

Yorum Gönder

Sonraki Kayıt Önceki Kayıt Ana Sayfa
Kaydol: Kayıt Yorumları (Atom)

Blog Arşivi

  • ▼  2007 (33)
    • ▼  Eylül (14)
      • Reference and Explanation
      • Main program for timing and testing
      • Brute force string searching
      • Improve by first character search
      • Call C library string match function
      • Improve by low frequency character search
      • Boyer-Moore-Horspool function
      • Main program for Boyer-Moore-Horspool function
      • 5 Types of Popularity for Ranking
      • How Web Search Engines Work
      • Quick Search algorithm
      • Main features
      • Description
      • The C code
    • ►  Ağustos (19)

Blogs

  • Adjustable Speed Control
  • Atom , RSS
  • Ligth Mix
  • Make Money
  • Make Money Fast
  • Pickpocket
  • Praying Mantis
  • Single and 3-Phase Induction Motors Using the PIC
  • The Simpsons Movie