DFA that begins with ' a ' but does not contain substring ' aab ' | Function for state A transition ; If at index 0 ' a ' if found then call stateB function with passing n [ 1 : ] to it ; If at index 0 ' b ' if found then call stateQ function with passing n to it ; Function for transition state B ; length ( ) of String become 0 then print Accepted ; If at index 0 ' a ' if found then call stateC function with passing n [ 1 : ] to it ; If at index 0 ' b ' if found then call stateD function with passing n [ 1 : ] to it ; Function for transition state C ; length ( ) of String become 0 then print Accepted ; If at index 0 ' a ' if found then call stateC function with passing n [ 1 : ] to it ; If at index 0 ' b ' if found then call stateQ function with passing n to it ; Function for transition state D ; length ( ) of String become 0 then print Accepted ; If at index 0 ' a ' if found then call stateC function with passing n [ 1 : ] to it ; If at index 0 ' b ' if found then call stateQ function with passing n to it ; Function for state Q transition ; In dead state it shows String not accepted ; Take String input ; Call stateA to check the input
function stateA ( n ) { if ( n [ 0 ] == ' ' ) { stateB ( n . substr ( 1 ) ) ; } else { stateQ ( n ) ; } } function stateB ( n ) { if ( n . length == 0 ) { document . write ( " " ) ; } else { if ( n [ 0 ] == ' ' ) stateC ( n . substr ( 1 ) ) ; else stateD ( n . substr ( 1 ) ) ; } } function stateC ( n ) { if ( n . length == 0 ) document . write ( " " ) ; else { if ( n [ 0 ] == ' ' ) stateC ( n . substr ( 1 ) ) ; else stateQ ( n ) ; } } function stateD ( n ) { if ( n . length ( ) == 0 ) document . write ( " " ) ; else { if ( n [ 0 ] == ' ' ) { stateB ( n . substr ( 1 ) ) ; } else { stateD ( n . substr ( 1 ) ) ; } } } function stateQ ( n ) { document . write ( " " ) ; } let n = " " ; stateA ( n ) ;