-1

What is the NFA that does not accept strings ending "101"?

3 Answers3

1

There are lots of NFAs (infinitely many, in fact) that work. Here is a simple one:

     /0-\      /1-+--------+--------+
     \  |      \  |        1        1
      \ V       \ V        |        |
----->[q0]--1-->[q1]--0-->[q2]--1-->q3
       ^                  |  ^      |
       |                  |  |      |
       \-------------0----/  \--0---/

This NFA happens also to be a completely deterministic DFA. That's OK. This DFA works by keeping track of the three most recently encountered input symbols. If the three most recently encountered were 000 or 100, the machine will end up in state q0. If the three most recently encountered were 111, 011 or 001, the machine will end up in state q1. If the three most recently encountered were 010 or 110 the machine will end up in state q2. If the three most recently encountered were 101 the machine will end up in q3. Those are all possibilities for the last three symbols seen and each one leaves the machine in either an accepting or non-accepting state correctly according to the language definition.

Patrick87
  • 27,682
  • 3
  • 38
  • 73
0

There can be "n" number of NFA possible for the finite automata.In non-deterministic finite automata on any input symbol trasitions to zero or more states is possible.To accept the string that does not ending with 101 one of the NFA is:

Transitions are:
∆(q0,0)={q0}
∆(q0,1)={q0,q1}

Here, intial state q0 on input symbol 0 can remain in the same state or can go to the next state q1 and on the input symbol 1 go to next state q1. q0 can be the final state.

∆(q1,0)={q2}
∆(q1,1)={q1}

here,q1 on input symbol 0 go to state q2 and on inputt symbol 1 remains in the same state.q1 can also be the final state.

∆(q2,0)={q2}
∆(q2,1)={q3}

Here, q2 on input symbol 0 remains in the same state and on the input symbol 1 goes to next state q3. q2 can also be final state.

∆{q3,0)={q2}
∆(q3,1)={q2,q1}

Here, q3 on symbol 0 goes to the state q2 and on input symbol 1 can go to q1 or q2. The state q3 can not be the final state as it accepts the string ending with 101.

Other NFA's can also be done for the same question which can also be correct.

enter image description here

Gilles-Antoine Nys
  • 1,481
  • 16
  • 21
0

we have to find nfa for the strings that dosen't end with 101 :

Consider 4 states q0,q1,q2,q3.The inputs are 0,1.

The transitions are as follows:
   δ(q0,0)=q0
   δ(q0,1)=q1
   δ(q1,0)=q2
   δ(q1,1)=q1
   δ(q2,0)=q0
   δ(q2,1)=q3
   δ(q3,0)=q2
   δ(q3,1)=q1

Here,q0,q1,q2 are final states and q3 is non final state.

Transition diagram

Netaji
  • 1
  • 2