RE & FA

download RE & FA

of 14

Transcript of RE & FA

  • 7/25/2019 RE & FA

    1/14

    Theory on FA1) Give the difference between NFA and DFA. [4]2) Define the following terms with e am!le [1"]

    1) #$mbol 2) Al!habet%) DFA 4) NFA&) 'ord.%) 'hat are the !ro!erties and limitations of Finite #tate (achine [*]4) Define and explain : [ 8]

    i) Language ii) Cartesian Product iii) Regular Expression iv) Kleene Closure.&) Define the following with e am!les+ [,]

    -leen clos re An al!habet /eg lar e !ression Formal lang age *) #how b$ !rinci!le of mathematical ind ction that n 4 0 4n 2 is divisible b$ % for all n " . [*]

    Examples on FA1) Design a Finite Atomata FA which acce!ts odd n mber of " # and even n mber of 1 s2) Design a finite a tomata which acce!ts even n mber of " s and odd n mber of 1 s.

    %) Design a DFA which acce!ts the odd n mber 1 s and an$ n mber of " s over =

    "3 1 .4) Design a finite a tomata that reads strings made ! of letters in the 'ord567A/89: and recogni;e those strings that contain the word 56A: as a s bstring. [,]&) Design FA that reads strings made ! of < "31 and acce!ts onl$ those stringswhich ends with 5""= or b$ 511=. [* ]*) Design a F#( to conce!t those strings having 1"1 or 11" as s bstring. [4]>) Design a DFA for a lang age of strings of " s and 1 s s ch that ? [1"]

    i) # bstring is 1". ii)#trings ending with 1"1.,) Design an F#( for divisibilit$ b$ % tester for a binar$ n mber. [*]9) Design a Finite State Machine for divisibility by 5 tester of a given decimal number. [ 8]1") Design a F#( for divisibilit$ tester of rinar$ n mber b$ 2. [,]11) Design an F#( for divisibilit$ b$ % tester for a nar$ n mber. [*]12) 9btain a DFA to acce!t strings of a s and b s s ch that ?

    @ < ' ' Ba C b ) s ch that N a B') mod % < " and N bB') mod 2 < " [1"]1%) 6onstr ct a NFA that acce!t an$ !ositive n mber of occ rrences of vario s stringsfrom the following lang age @ given b$ @ < a3 b E ends with aab). [*]14) Construct the NFA for the language of all strings that begin and end with same symbolover the alphabet = "3 1 . [4]1&) Design an NFA to acce!t set of all strings which end with "". 'here

    8 < "3 1 . 6onvert this NFA into its e ivalent DFA. [,]16) Construct a NFA that accept any positive number of occurrences of various strings fromthe following language L given by @={ {a3b} ends with aab) . [ 6]17) Construct a NFA and then equivalent DFA accepting strings over {0, 1}, whose everyblock of 4 consecutive symbol, contain at least 3 zeroes (i.e. 0s) [ 10]1,) 6onstr ct a NFA that acce!t the set of strings in B"C1) s ch that some two " s arese!arated b$ string whose length is 4i3 for some i

  • 7/25/2019 RE & FA

    2/14

    RE to FA1) 6onstr ct a DFA for the reg lar e !ression BaCb) Bbaaa) [*]2) Describe in Inglish lang age acce!ted b$ /.I. B"C1) " [2]%) 6onstr ct DFA for the following reg lar e !ression /I < BaCb) abb. [*]4) For each of the following reg lar e !ression3 draw an Finite A tomata recogni;ing

    the corres!onding lang age [1"]1) B1 C 1" C 11") "2) 1 B"1 C 1") C "B11C1")%) B"1" C "") B1")4) 1 B1C1") C 1"B"C"1)

    &) 6onstr ct NFA for the following reg lar e !ression. (0 + (0 + 1)*) + [*]*) 6onstr ct a DFA with red ced states e ivalent to the reg lar e !ression

    1" CB"C11)" 1. [1"]7) Construct NFA from the following regular expressions : [ 8]

    i) 0*1*2* ii) (00 + )* (10)*.

    ,) 6onstr ct DFA for following reg lar e !ression /I < b Ba C b) a . [*]H) 6onstr ct DFA for following reg lar e !ression /I < Ba C b) a b b. [*]1") For the following reg lar e !ression3 draw an FA recogni;ing the corres!ondinglang age. r < B1C1") " [*]11) Design an NFA e ivalent to following /I? [*]

    B" C 1) B"" C 11) B" C 1)12) For each of the following regular expression, draw an Finite Automata recognizingthe corresponding language. [ 10]

    1) (10 + 1 + 110)*12) 1 (10 + 01)* + 0 (10 + 11)*

    3) (010 + 100)* (10)4) 1 (1 + 10)* + 10 (0 + 01)*1%) 6onstr ct the finite a tomata e ivalent to the following reg lar set and describe inInglish set denoted b$ following reg lar set [,]

    1) 1" C B" C 11) " 12) "1 [BB1") C 111) C "] 1

    14) Describe in sim!le english the lang age defined b$ following /I+ [4]i) BaCb) aa BaCb) ii) BbCba)

    iii) a BaCb) b iv) aC b cC

  • 7/25/2019 RE & FA

    3/14

    Language to RE1) Find all !ossible reg lar e !ression ever @ 6 "31 [4]

    i) :he set J all !ossible string containing 5"1=.ii) :he set of all string that do not end with 5"1=.

    2) Find a /I corres!onding to each of the following s bsets of "3 1 . [*]

    1) :he lang age of all strings containing e actl$ two " s.2) :he lang age of all strings containing atleast two " s.%) :he lang age of all strings not containing the s bstring "".

    %) Give /I for the following lang ages over = {"31}. [*]i) #trings containing even n mber of 1 s followed b$ odd n mber of " s.ii) #trings that do not contain three consec tive " s.iii) #trings that contain at most three " s.

    4) Find the regular expression corresponding to each of the following subset of {0, 1}*a) The language of all strings not containing the substring 000b) The language of all strings that do not contain then substring 110

    c) The language of all strings containing both 101 and 010 as substring. [ 10]&) 'rite the reg lar e !ressions for + [,]i) = a3b3c the lang age containing strings3 s ch that each string has 5an$n mber of a s followed b$ an$ n mber of c s=.ii) = "3132 3 and lang age set @Br) < "323"13213"1132113"1113...iii) = "31 and lang age set @Br) < ""3"1"3"11"3"111"3....iv) @ang age defined over = a3b has to have the strings beginning with Ka andnot to have two consec tive a sv) = a3b s ch that each of string do not have aa or bb as a s bstring in it.vi) = "31) the lang age s ch that it contains strings with even n mber of " s.

    *) 6onsider the two reg lar e !ressionsr < " C 1 # < "1 C 1" C 1 " C B" 1)1) Find a string corres!onding to s b t not to r.2) Find a string corres!onding to both r and s.

    %) Find a string in "3 1 corres!onding to neither r nor s. [*]>) Find the reg lar e !ressions re!resenting the following sets + [*]

    i) :he set of all strings over a3 b with three consec tive b s.ii) :he set of all strings over "31 beginning with "".iii) :he set of all strings over "31 ending with "" and beginning with 1.

    ,) @et / < B13 2)3 B23 %)3 B13 4)3 B43 2)3 B%3 4) Find / C3 / . [4]H) Find all strings of length & or less in the reg lar set re!resented b$ the following ?

    i) Bab C a) Baa C b) [*]ii) Ba b C b a) a

    iii) a C Bab C a)

  • 7/25/2019 RE & FA

    4/14

    Show that (Prove that)

    1) Prove the following :(1+00*1) + (1+00*1) (0+10*1)* (0+10*1) = 0*1(0+10*1)*. [4]

    2) Show that - [6]i) R*R = R + ii) (P + Q)* = (P*Q*)* iii) (R*)* = R*

    3) Prove or disprove the following for regular expression r1s and t.1) (rs + r) * r = r (sr + r)* 2) (r + s) * = r* + s*4) Prove : [4]

    a) * = b) (r*s*) = (r+s)*.5) Let L be a language. It is clear from the definition that L + L *. Under what circumstancesare they equal ? [4]6) Prove that for any , * = ** [4]

    Properties and Application of RE1) State and explain in detail the closure properties of regular sets [8]2) State with brief explanation FSM properties and limitations. [6]3) Explain your answer in each of the following : [6]

    1) Every subset of a regular language is regular2) Every regular language has a regular proper subset.

    4) With suitable example, prove the following theorem : [10]The regular sets are closed under union, concatenation, and kleene closure.

    5) Explain your answer in each of the following : [6]1. Every subset of a regular language is regular2) Every regular language has a regular proper subset.

    6) With suitable example, prove the following theorem The regular sets are closed underunion, concatenation, and kleene closure. [8]7) Let L be any subset of 0*. Prove that L* is regular. [4]8) Explain the use of regular expressions in unix with any one example. [4]9) Write a regular expression to identify valid decimal integer constant for C language. JustifyRE with example. [4]10) Write a regular expression to search dat (.dat) file(s) having starting characterp and ending with zw. Justify RE with example(s). [4]11) Explain the application of RE in lexical analysis phase of compiler [6]

    Pumping Lemma1) State and explain Pumping Lemma for regular sets. [6]2) Find out whether given languages are regular or not

    a) L = {ww|w {0,1}*}b) L = {1 k | k = n2 ,n > =1} .c) L = {xy/x, y {0, 1} * and y is x}. [8]

    3) Show whether the language L = {0 n 1 2n | n>0} is regular or not. [6]4) Let L = {0 n | n is prime} show that L is not regular. [6]5) Show that the set L ={a i 2| i 1} is not regular. [6]

  • 7/25/2019 RE & FA

    5/14

    Find the Language1) I !ress the lang age acce!ted b$ following :ransition Gra!h in the form of reg lar e !ressions. *

    2) A transition table is given for another NFA with NL@@ with seven state. *

    a) Draw a transition diagram b) 6alc late B13ba).%) 6onsider the following F A

    Answer the following estions +i) 'hat is the ma length of string acce!ted b$ this F A ii) 'hat are the words acce!ted b$ this F A [4 ]

  • 7/25/2019 RE & FA

    6/14

    FA to DFA

    1) #how ste!wise !rocess of constr cting DFA e ivalent to the NFA + [*]

    2) 6onstr ct DFA e ivalent to NFA B !3 3 r3 s 3 3 1 33 !3 3 s ) [*]

    %) 6onstr ct DFA e ivalent to NFA B !3 3 r3 s 3 3 1 33 !3 s ). [*]

    4) Convert the following NFA to its equivalent DFA. [ 8]

  • 7/25/2019 RE & FA

    7/14

    &) :he transition table of a NFA K( is given below. constr ct a DFA e ivalentto (. is [, ]

    *) 6onvert the following NFA into e ivalent DFA [*]

    ( =({ " 3 1}, { "31 }, 3 "3 { 1 }) whereB " 3 ") = " 3 1 3 B " 31) = 1 3B " 3 ") = , = B 31) " 3 1

    >) 6onstr ct an e ivalent DFA fer given NFA m< 3!3r3s3t 3 "31 3 3!3 t [1"]where is defined in the following table.

  • 7/25/2019 RE & FA

    8/14

    FA with !oves to FA without !oves

    1) 6onstr ct NFA witho t moves for the following NFA with moves. [*]

    2) 6onsider the following NFA with ?transitions. 6onvert this NFA to NFAwitho t ?moves + [,]

    %) 6onsider the following NFA with I?transitions. 6onvert this NFA to [1"]1) NFA witho t ?moves 2) DFA

    4) Convert the following NFA- to its equivalent DFA. [ 8]

    &) 6onvert the given NFA0 to an NFA. [* ]

  • 7/25/2019 RE & FA

    9/14

    E"uivalence of two FA#s

    1) Find o t whether (1 and (2 are e ivalent. [* ]

    2) Find o t whether (1 and (2 are e ivalent. [*]

    %) 6onvert the following a tomata given in fig. Bi) and fig. Bii) to e ivalent reg lare !ression. [1"]

  • 7/25/2019 RE & FA

    10/14

    FA to RE ( Arden$s theore!% )1) 6onstr ct reg lar e !ression for following transition diagram + [*]

    2) 6onstr ct reg lar e !ression for following transition diagram. [*]

    3) Obtain regular expression for the following FA. [ 8]

    4) 6onsider the following transition diagram and convert it to its e ivalent reg lar e !ression sing Arden s theorem. 6onsider the transition diagram given below. Mrovethat the strings recogni;ed are + Ba C a Bb C a a) b) a Bb C a a) a. [* ]

    &) 6onsider the following transition diagram. 6onvert it to the e ivalent reg lar

    e !ression

  • 7/25/2019 RE & FA

    11/14

    *) 6onstr ct a reg lar e !ression corres!onding to the state diagram given below + [* ]

    >) 6onsider the following transition diagram convert it to e ivalent reg lar e !ression sing Arden s theorem. [1"]

    ,) Mrove that the FA whose transition gra!h is as shown below acce!ts [,]:he set of all strings over the al!habet "31 with an e al n mber 9f " s and 1 s3 s chthat each !refi has atmost one more " than 1 s And atmost one more 1 than " s.

  • 7/25/2019 RE & FA

    12/14

    E&a!ples on 'oore 'achine1) Design a (oore machine that will read se ences made ! of the letters A3 I3 83 93 Land will give as o t! t the same se ence e ce!t in case where 8 directl$ follows an I38 will be changed to L. [,]2) I !lain (oore machine and (eal$ machine with s itable e am!le. 7ow do

    we constr ct e ivalent (eal$ machine for given (oore machine [4 ]%) Give the (eal$ and (oore machine for the following !rocesses. [,]5For in! t from B" C 1) 3 if in! ts ends in 1"13 o t! t O if in! t ends in 11"3 o t! t P3otherwise o t! t Q=4) Design a (oore machine to generate 1 s com!liment of the given binar$ n mber. [4]&) Design a (oore machine which will recogni;e the lang age of all words of the formBaCb) aaBaCb) . @et the machine dis!la$ 5A= for acce!tance and 5/= for reRection of words.*) Design a (oore and (eal$ machine to generate 1 s com!lement of a given binar$n mber.

    E&a!ples on 'ealy 'achine1) Design a meal$ machine fer binar$ in! t se ence s ch that if se ence ends with1""3 the o t! t is 1 otherwise o t! t is ". [*]2) Design a (eal$ (achine to find o t 2 s com!lement of a given binar$ n mber. [*]%) Design a (eal$ machine that acce!ts strings ending in K"" and K11 . 6onvert the(eal$ machine to the e ivalent (oore machine.4) Give the (eal$ and (oore machine for the following !rocesses. 5For in! t fromB"C1) 3 if in! ts ends in 1"13 o t! t O if in! t ends in 11"3 o t! t P3 otherwise o t! t

    Q=.Mealy to Moore1) Consider the following Mealy machine, construct a Moore machine equivalent to it. [ 4]

  • 7/25/2019 RE & FA

    13/14

    2) 6onvert the following meal$ machine into e ivalent (oore machine. [1"]

    %) 6onvert the following (eal$ machine to its e ivalent (oore machine ?[*]

    4) Convert the following Mealy machine to Moore machine and what is the output ofthis mealy machine ? [ 6]

    &) #tate tr e or falsei) (oore machine can have arbitrar$ n mber of final states.ii) (eal$ machine can have arbitrar$ n mber of start states. [2]

    *) Give the difference between (eal$ machine and (oore machine. [4]>) Define the following terms with e am!le. [*]

    1) Sasic machine 2) (oore (achine %)(eal$ machine

  • 7/25/2019 RE & FA

    14/14

    Moore to Mealy

    1) 6onstr ct a (oore (achine e ivalent to the (eal$ (achine ( given below. is [* ]

    2) 6onvert the following (oore machine to (eal$ machine. [*]