<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ta.in.th/index.php?action=history&amp;feed=atom&amp;title=Knuth-Morris-Pratt_%28KMP%29</id>
	<title>Knuth-Morris-Pratt (KMP) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ta.in.th/index.php?action=history&amp;feed=atom&amp;title=Knuth-Morris-Pratt_%28KMP%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.ta.in.th/index.php?title=Knuth-Morris-Pratt_(KMP)&amp;action=history"/>
	<updated>2026-06-16T23:29:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0-alpha</generator>
	<entry>
		<id>https://wiki.ta.in.th/index.php?title=Knuth-Morris-Pratt_(KMP)&amp;diff=94&amp;oldid=prev</id>
		<title>Tata: Created page with &quot;อันนี้เป็น snippet ที่ copy มาจาก http://www.cprogramming.com/snippets/source-code/knuthmorrispratt-kmp-string-search-algorithm เห็...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.ta.in.th/index.php?title=Knuth-Morris-Pratt_(KMP)&amp;diff=94&amp;oldid=prev"/>
		<updated>2019-03-07T17:14:28Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;อันนี้เป็น snippet ที่ copy มาจาก http://www.cprogramming.com/snippets/source-code/knuthmorrispratt-kmp-string-search-algorithm เห็...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;อันนี้เป็น snippet ที่ copy มาจาก http://www.cprogramming.com/snippets/source-code/knuthmorrispratt-kmp-string-search-algorithm&lt;br /&gt;
เห็นว่า string matching เรียนใน สอวน. ค่าย 2&lt;br /&gt;
&lt;br /&gt;
 const char *kmp_search(const char *text, const char *pattern)&lt;br /&gt;
 {&lt;br /&gt;
     int *T;&lt;br /&gt;
     int i, j;&lt;br /&gt;
     const char *result = NULL;&lt;br /&gt;
  &lt;br /&gt;
     if (pattern[0] == '\0')&lt;br /&gt;
         return text;&lt;br /&gt;
  &lt;br /&gt;
     /* Construct the lookup table */&lt;br /&gt;
     T = (int*) malloc((strlen(pattern)+1) * sizeof(int) );&lt;br /&gt;
     T[0] = -1;&lt;br /&gt;
     for (i=0; pattern[i] != '\0'; i++) {&lt;br /&gt;
         T[i+1] = T[i] + 1;&lt;br /&gt;
         while (T[i+1] &amp;gt; 0 &amp;amp;&amp;amp; pattern[i] != pattern[T[i+1]-1])&lt;br /&gt;
             T[i+1] = T[T[i+1]-1] + 1;&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     /* Perform the search */&lt;br /&gt;
     for (i=j=0; text[i] != '\0'; ) {&lt;br /&gt;
         if (j &amp;lt; 0 || text[i] == pattern[j]) {&lt;br /&gt;
             ++i, ++j;&lt;br /&gt;
             if (pattern[j] == '\0') {&lt;br /&gt;
                 result = text+i-j;&lt;br /&gt;
                 break;&lt;br /&gt;
             }&lt;br /&gt;
         }&lt;br /&gt;
         else j = T[j];&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     free(T);&lt;br /&gt;
     return result;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Tata</name></author>
		
	</entry>
</feed>