title: Pattern-Matching Algorithm
body: <p>This is slide from class at my University, it about Pattern-Matching Algotithm..
   <img src="https://i.stack.imgur.com/W9ALj.png" alt="enter image description here"></p>
  
  <p>And I try to code it in Java below;</p>
  
  <pre><code>            // Get values for both the text T1,T2 ... Tn and the pattern P1 P2 ... Pm
              String[] T = {"Java", "is", "too", "delicious", ", Dr.Java", "is", "confrim!"};
              String[] P = { "is", "too"};
              // Get values for n and m, the size of the text and the pattern, respectively
              int n = T.length;
              int m = P.length;
              // Set k1 the starting location for the attempted match, to 1
              int k = 0;
  
              // While(k&lt;=(n-m+1))do
              while (k &lt;= (n - m + 1) - 1) {
                      // Set the value of i to 1
                      int i = 0;
                      // Set the value of Mismatch NO
                      boolean Mismatch = true; // Not found (true - NO)
  
                      // While both (i&lt;=m) and (Mismatch = NO) do
                      while ((i &lt;= m - 1) &amp;&amp; (Mismatch)) { // if Not found (true - NO)
                              // if Pi != Tk+(i-1) then
                              if (P[i].equals(T[k])) { // if Found(true)
                                      // Set Mismatch to YES
                                      Mismatch = false; // Found (false - YES)
                                      // Else
                              } else {
                                      // Increment i by 1 (to move to the next character)
                                      i = i + 1;
                              }
                              // End of the loop
                      }
                      // If mismatch = NO then
                      if (!Mismatch) { // if Found (false - YES)
                              // Print the message 'There is a match at position'
                              System.out.print("There is a match at position ");
                              // Print the value of k
                              System.out.println(k);
                      }
                      // Increment k by 1
                      k = k + 1;
                      // Enf of the loop
              }
              // Stop, we are finished
  </code></pre>
  
  <p>But I have a question! why in pseudo code version, check if P not equal T ? I think it would rather to be check if P equal T (How it difference with my version? , sorry for my terrible English)</p>