Question

In: Computer Science

Draw the NFA for language L2 = { w | w ends in 12}. Alphabet {0,1,2}

Draw the NFA for language L2 = { w | w ends in 12}. Alphabet {0,1,2}

Solutions

Expert Solution

Answer: - Draw the NFA for language L2 = { w | w ends in 12}. Alphabet {0,1,2}

Now we have to draw a state diagram of a NFA with recognise the above language.

NFA (Non deterministic finite automata) is as follows:-

Formal Definition, an NFA is a 5-tuple NFA= (Q, Σ, q0, F, δ) where Q=set of Possible total states, Σ=input alphabets, q0 =initial states, F=set of final states, δ= transition function mapping between (Q*Σ--->2Q).

NFA basically gives two outputs for giving single inputs. So it is called NFA.

For example

Here in above figure of NFA if we give input 0 to the state Q0 we will reach to Two states Q0 as well as Q1 it means that we have two choices .it means that we are not able to decides in which   state we have to move either Q0 or Q1 so that there is no uniqueness is there in above figure. So that it is called NFA. Here Q1 is the final states, Q0 is the initial state, a is the input alphabet.

       Transition Table of above NFA

Present State

Input

Output State

    -->Q0

a

(Q0,Q1)

        Q1

a

Q1

Now consider our given problem of NFA Here we have given the Language

Draw the NFA for language L2 = { w | w ends in 12}. Alphabet {0,1,2}

Note: We are assuming that we have to make a NFA of the above condition with three states.

So first of all we have to identify which strings are the parts of our given Language.

First of all we have to draw Regular expression for the above problems:-

Regular Expression: -        (0+1+2)*12

So in above problem it is clearly mentioned that Our NFA will accept such kind of strings which is always ended with 12. It means that before 12 it could be any string are possible of 0, 1, and 2.

Meanwhile   last two strings is fixed

Here in above figure first position could be any string of 0,1,2 that is all the possible combination of 0,1,2   so it can be represented by Regular expression    (0,1,2)*

And for fulfilling the our condition of a given Language we must ended with our string of 12. So 12 is concatenate with Regular expression    (0, 1, 2)*.

So final Regular expression of the above Language is as follow:-

Regular expression RE = (0+1+2)*12

L = {12, 112, 1112, 1112..., 012, 0112, 0212, 00012, 11112, 101012,.....}

In given Language L it could accept 12 if we put * as null we will get 12 only string, it can accept 112, it can accept 1112, it can accept 11112, it can accept 00110012 and many more strings.

Note:- Here in above Regular Expression 12 is the minimal String of a given Langauge.because if we Put (0+1+2)* as a Null then we will get only 12 which is called Minimal String.

In summary we can say that in Given Language L =( it can accept such kind of strings of all the possible combination of 0,1,2 followed by 12).

So keeping in mind all such condition we are going to construct NFA for the given Language

L2 = { w | w ends in 12}. Alphabet {0,1,2}

Here from above NFA all the valid strings is accepted by given NFA

And rejected all invalid states.

L = {12, 112, 1112, 1112..., 012, 0112, 0212, 00012, 11112, 101012,.....}

Here in above Fig “2” Q0 is initial state where input is processed Q1 is intermediary state and Q2 is last state which is final state. And we have input alphabet is Σ (Sigma) over the (0, 1).

Present State

    Input

Output State

    --->Q0

0

Q0

        Q0

1

Q0,Q1

        Q0

2

Q0

        Q1

2

Q2

                                               Transition Table of Fig “2”

Justify why your NFA rejects the String   “11”           

We have String   “11” we have to processed it one by one from state Q0.

Here in given Input Processing Q0 states give input 1 we will reach to state Q0 now give Q0 to input 1 we will reach to Q0 as will Q1. Now there is no transition is there on    (Q0, Q1) due to end of string in Fig “2”. Machine will halt on such a non final state and move to in deadlock. So that string “11” is rejected by the NFA.

However machine accepting string   “012”.

Here in given Input Processing Q0 states give input 1 we will reach to state Q0 now give Q0 to input 1 we will reach to Q0 as will Q1. Now there is no transition is there on    (Q0, Q1) due to end of string in Fig “2”. Machine will halt on such a non final state and move to in deadlock. So that string “11” is rejected by the NFA.

However machine accepting string   “012”.

Here machine will stop on input 012 and reach on final state Q2 which is a final state so that input “012” is accepted by NFA.

Note: - one important point is that we are building NFA so it may be possible that we will reach to multiple states with giving single input. For example in accepting “012” string       (Q0, 0)-->Q0, (Q0, 1) --->(Q0, Q1) if we take Q0 state than (Q0, 2)--->Q0 which is non final state. And if we take (Q1,2)--->Q2 which is final state.

          End of Answer.


Related Solutions

Draw an NFA for the following language then convert to a DFA: L = {w :...
Draw an NFA for the following language then convert to a DFA: L = {w : |w| is odd or |w| is a multiple of 4} where Σ = {0, 1}
5. Ternary strings. A ternary string is a word from the alphabet {0,1,2}{0,1,2}. For example, 022101022101...
5. Ternary strings. A ternary string is a word from the alphabet {0,1,2}{0,1,2}. For example, 022101022101 is a ternary string of length 6. (a) Enumerate all ternary strings of length 2. (b) Generalize: how many ternary strings have length r? (c) A ternary string of length 6 is to be made. How many ways can we choose how many 0's, 1's, and 2's to include in the string? (d) A ternary string of length 6 is to have two 0's,...
Consider the two languages below: L1 = {w | w є {0,1,2}* and is of the...
Consider the two languages below: L1 = {w | w є {0,1,2}* and is of the form 0i1j2k where i, j and k ≥ 0 and i = j or j = k} L2 = {w | w є {0,1,2}* and is of the form 0i1j2k where i, j and k ≥ 0} One of the languages in the above problem is regular. Which one? Prove it. Prove that the OTHER one is not regular. Is the non-regular one context...
Draw PDA transition diagram for the following language: The set of strings over the alphabet {x,...
Draw PDA transition diagram for the following language: The set of strings over the alphabet {x, y} where 2 * (# of x's) = 3 * (#y's) That is, if we let nx be the number of x's and ny be the number of y's, then the strings in these language are those where 2nx = 3ny Try to find a PDA that is as simple and elegant as possible (do not convert from CFG). ------------------------------------------------------------------------------------------------------------------ USE Notation between transition:...
For a given language L = { w | na(w) + nb(w) = nc(w) } where...
For a given language L = { w | na(w) + nb(w) = nc(w) } where S = G = {a, b, c} Looking for answer to 3 Construct a PDA M that accepts L with S = G = {a, b, c} Show the sequence of instantaneous descriptions for the acceptance of acacbcbc by M in 1). Give a CFG G that generates L, L(G) = L.
Given a regular language A, define L2 = { xz | there exists y Σ*, xyz...
Given a regular language A, define L2 = { xz | there exists y Σ*, xyz A, |x|=|z|, |y| = 2 }. Decide with a formal proof if L2 is (a) regular; or (b) not regular but context-free; or (c) not context-free.
Draw DFA C = { w is an element of {a,b}* and #a(w) is even and...
Draw DFA C = { w is an element of {a,b}* and #a(w) is even and #b(w) us a multiple of 3)
1. Prove the language L is not regular, over the alphabet Σ = {a, b}. L...
1. Prove the language L is not regular, over the alphabet Σ = {a, b}. L = { aib2i : i > 0} 2) Prove the language M is not regular, over the alphabet Σ = {a, b}. M = { wwR : w is an element of Σ* i.e. w is any string, and wR means the string w written in reverse}. In other words, language M is even-length palindromes.
What are some similiarities and differences between the development of L1 (native language) and L2 (target...
What are some similiarities and differences between the development of L1 (native language) and L2 (target language)?
Define a Turing machine TM3 that decides language L3 = { w | w ∈ Σ*,...
Define a Turing machine TM3 that decides language L3 = { w | w ∈ Σ*, #a(w) = #b(w) } over the alphabet Σ = {a, b}. IMPLEMENT USING JFLAP NO PAPER SOLUTION
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT