Frage

I am given a simple statement: Construct a DFA over alphabet {0, 1} that accepts all the strings that end in 101?

My question is that what will be the steps to design it? Or design an NFA, because then I know the clear steps yo convert an NFA to a DFA, so I will then convert the NFA to the DFA.

Note:- It is just a minor course for me, so I have never studied anything like regular expressions, or any algorithms probably used to construct DFA's.

War es hilfreich?

Lösung

If you want more of an explanation on how I derived this, I'd be happy to explain, but for now I just drew the DFA and explained each state.

Sorry about the screenshot...I didn't know how to convert it straight to an image.

DFA

  • On input 0 at state 0, it loops back to itself. On 1, it prepares itself to end because it could possibly be '101'.

  • q1 loops to itself on input 1 because it's still preparing to end on '101'. Input '0' on q1 means it is preparing for input '10', so it goes to q2.

  • Input '0' on q2 breaks the whole cycle and goes back to q0. Input '1' results in moving to q3, the accepting state.

  • Any input on q3 results in going back to whatever point in the cycle the input corresponds with.

  • That is, on '1' it goes back to q1, or the state where the first '1' was encountered in '101', preparing to end.

  • On '0', it goes to q2 because in order to get to q3, there must have been an input of '1' from q2, so no matter what, the last two input symbols are '10' now.

TikZ DFA examples.

Andere Tipps

Here,the string should end with 101.So we need to draw nfa for it and later convert it into DFA Here the total states are A,B,C,D. I will upload an image here. In that I have drawn NFA and then I have drawn transition table for it. And then I have drawn transition table for conversion of NFA to DFA. I also drawn DFA for your sake.

In NFA, when a specific input is given to the current state, the machine goes to multiple states. It can have zero, one or more than one move on a given input symbol. On the other hand, in DFA, when a specific input is given to the current state, the machine goes to only one state. DFA has only one move on a given input State.

THE STEPS FOR CONVERTING NFA TO DFA: Step 1: Initially Q' = ϕ

Step 2: Add q0 of NFA to Q'. Then find the transitions from this start state.

Step 3: In Q', find the possible set of states for each input symbol. If this set of states is not in Q', then add it to Q'.

Step 4: In DFA, the final state will be all the states which contain F(final states of NFA)

View the image here Click here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top