End position is checked using the string length value . q0 is the starting state . q1 and q2 are intermediate states . q3 and q4 are final states .
static void q1 ( string s , int i ) { Console . Write ( " q1 - > " ) ; if ( i == s . Length ) { Console . WriteLine ( " NO " ) ; return ; }