Finite Automata String Matcher
<p>I am trying to build a FA string matcher using java. I have the following pseudocode.</p>

<p><a href="https://i.stack.imgur.com/vkpmQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vkpmQ.png" alt="enter image description here"></a> </p>

<p>For the Finite-Automata-Matcher algorithm to work the transition function has to be computed. The following algorithm Compute-Transition-Function computes given a the pattern P and the alphabet sigma.</p>

<p><a href="https://i.stack.imgur.com/6guSu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6guSu.png" alt="enter image description here"></a></p>

<p>In the above code I couldn't understand where did min(m + 1, q + 2) come from. 
(I did understand why it is k = min(m + 1, q + 2) instead of k = min(m, q + 1) but why we want the minimum of m and q+1 in the first place)</p>

<p>In between lines at 5-7 it decreases k by one until Pk is a suffix of Pqa, but I couldn't understand what Pqa stands for.</p>

<p>Also, how can I convert the line 8 to a java code? Would a two-dimensional array be sufficient or do I need another data structure.</p>

<p>A related question: <a href="https://stackoverflow.com/questions/8757446/string-matching-with-finite-automata">string matching with finite automata</a></p>