5
Shivalik College of Engineering Question Bank Subject: Theory of Automata & Formal Languages Course Code: TCS-403 Branch: CSE Semester: IV Unit - I 1. Define the following with suitable examples. (a) Alphabet (b) Language (c) Kleene’s closure (d) Positive closure 2. (i) Draw a block diagram to define automata. Also explain deterministic and non-deterministic automata. What are the limitations & Applications of Finite Automata? (ii) What do you know about compliment and reverse of a language? Explain both of these by giving suitable examples. 3. (i) What is a generalized transition graph? Explain with a suitable example. Also explain Chomsky heirarchy by taking suitable examples. (ii) Define grammar and its types in theory of computation. Briefly explain Chomsky hierarchy. 4. Design a DFA over {0, 1} for the following:- (i) that accepts the set of all strings such that the 3 rd symbol from the right end is 1. (ii) that accepts the set of string not containing 011 as a sub string. (iii) That accepts the set of string not ending with double letter. 5. Make a DFA that accepts the following languages over the alphabet Є = {0,1} (a) No. of 1’s is even (b) No. of 1 is odd (c) No. of 1’s as well as 0’s is even (d) No. of 1’s as well as 0’s is odd 6. Make a DFA for the following languages over the alphabet Є = {0,1} (a) All strings of length atmost 5 (b) All strings with exactly two 1’s (c) All strings containing atleast two 0’s (d) All strings containing atmost two 0’s (e) All strings starting with 1 and length of string is divisible by 3 7. (i)Design a DFA for a set of strings over the alphabet {0, 1} such that the number of 0s is divisible by 5 and number of 1s is divisible by 3.

Question bank toafl

Embed Size (px)

Citation preview

Page 1: Question bank toafl

Shivalik College of EngineeringQuestion Bank

Subject: Theory of Automata &

Formal Languages

Course Code: TCS-403

Branch: CSE Semester: IV

Unit - I1. Define the following with suitable examples.

(a) Alphabet(b) Language(c) Kleene’s closure(d) Positive closure

2. (i) Draw a block diagram to define automata. Also explain deterministic and non-deterministic automata. What are the limitations & Applications of Finite Automata?(ii) What do you know about compliment and reverse of a language? Explain both of these by giving suitable examples.

3. (i) What is a generalized transition graph? Explain with a suitable example. Also explain Chomsky heirarchy by taking suitable examples.(ii) Define grammar and its types in theory of computation. Briefly explain Chomsky hierarchy.

4. Design a DFA over {0, 1} for the following:-(i) that accepts the set of all strings such that the 3rd symbol from the right end is 1.(ii) that accepts the set of string not containing 011 as a sub string.(iii) That accepts the set of string not ending with double letter.

5. Make a DFA that accepts the following languages over the alphabet Є = {0,1}(a) No. of 1’s is even

(b) No. of 1 is odd

(c) No. of 1’s as well as 0’s is even(d) No. of 1’s as well as 0’s is odd

6. Make a DFA for the following languages over the alphabet Є = {0,1}(a) All strings of length atmost 5(b) All strings with exactly two 1’s(c) All strings containing atleast two 0’s(d) All strings containing atmost two 0’s(e) All strings starting with 1 and length of string is divisible by 3

7. (i)Design a DFA for a set of strings over the alphabet {0, 1} such that the number of 0s is divisible by 5 and number of 1s is divisible by 3.(ii)Design a DFA for the language containing strings over the alphabet {0, 1} in which leftmost symbol differs from the rightmost symbol.(iii)Design a DFA for set of all strings over {a, b} ending in

(a) eitherab or ba.(b) Either aa or bb.(c) Neither aa or bb.

Unit – II

1. What do you understand by “Finite automata with output function “? What is the output function for Mealy and Moore machine? Also define these 2 machines.

2. Differentiate between (i) Moore machine and Mealy machine by taking a suitable example.(ii) DFA & NFA

Page 2: Question bank toafl

Shivalik College of EngineeringQuestion Bank

Subject: Theory of Automata &

Formal Languages

Course Code: TCS-403

Branch: CSE Semester: IV

3. Construct a Mealy Machine for the following and then convert them into equivalent Moore machines

(a) which can output EVEN, ODD accordingly as the total number of 1s encountered is even or odd. The input symbols are 0 & 1.

(b) that gives an output 1 if the input string ends in bab.4. Construct a Moore Machine for the following and then convert them into equivalent Mealy

machines.(a) that gives an output 1 if the input string ends in bab.(b) that accepts strings ending in “00” and “11”.

5. Design NFA to recognize the following sets of string : abc, abd, and aacd. Assume the alphabet is {a,b,c,d}.

6. Define regular expression. Also give regular expression generating the following Languages over ∑ = {0,1}

(i) L1= {w|w contains atleast three 1’s} (ii) L2= {w|w has length at least 3 and its third symbol is 0}

(iii) L3= {w|w doesn’t contain the substring (iv) L4= {w|every odd position of w is a 1}

(iv) L5= {w|w contains atleast two 0’s and at most one 1’s}7. Consider the following Transition Table of an NFA. Convert it into its equivalent DFA.

(i) δ 0 1

->p p, r p

q r, s q

r* p, q r

s* q, r ф

(ii)

8. Determine the total number of States in the Minimalistic DFA for the given DFA.

Unit – III

1. Give the Formal definitions for the following: -Context Free Grammar, Context Free Language, Context Sensitive Grammar, Chomsky Normal Form, Greibach Normal Form

2. Simplify the given grammar(a) S->0A0|1B1|BB, A->C, B->S|A, C->S|ε

Page 3: Question bank toafl

Shivalik College of EngineeringQuestion Bank

Subject: Theory of Automata &

Formal Languages

Course Code: TCS-403

Branch: CSE Semester: IV

(b) S->aAa, A->Sb|bCC, C->abb, E->aC(c) S→aAa , A→bBB, B→ab , C→aB

(d) S→AB, A→a, B→C|b, C→D, D→E, E→a3. Consider the Grammar : S→aB|bA, A→aS|bAA|a, B→bS|aBB|b

For the string “aaabbabbba” find(a) Leftmost derivation(b) Rightmost derivation(c) Parse Tree

4. Find the Context Free Grammars for the following languages:(a) L = { anbn : n <= m+3, n, m>=0)}(b) L = {w belongs to (a+b)* : na(w)!= nb(w)}(c) L = {a*b*}

5. What do you understand by Ambiguous Grammar? Prove that -(a) G is ambiguous, if G is the grammar S → S b s |a(b) G is ambiguous, if G is the grammar S → a S b| SS |λ(c) G is ambiguous, if G is the grammar S → AB | aaB, A → a | Aa, B → b(d) G is ambiguous, if G is the grammar S→a|abSb|aAb, A→bS|aAAb(e) G is ambiguous, if G is the grammar S→aB|ab, A→aAB, B→ABb|b

6. Obtain the equivalent CNF for the given Grammar.(a) S → ABa, A → aab, B → AC(b) S→AA|0 , A→SS|1(c) S→ASA|Ba, A→B|S, B→c(d) S→1A|0B, A→1AA|0S|0, B→0BB|1s|1(e) S→a|abSb|aAb, A→bS|aAAb

Unit – IV

1. (a)Define Pushdown Automation (PDA). Draw the model of PDA and explain its working. Is there any difference between FA and PDA, explain it.(b)What do you understand by Auxiliary PDA? Explain with the help of a neat diagram. Also explain 2-PDA.

2. Show that the language L = {0n1n: n>=1} U{0n12n : n>=1} is a Context Free Language that is not accepted by any Deterministic PDA.

3. Construct a CFG generating each of the following language and hence a PDA accepting each of them by empty store

(i) {anbn such that n>=1} ᴜ { amb2m such that m>=1}(ii) { anbman such that m,n>=1}ᴜ {ancn such that n ≥ 1}(iii) {x such that na(x)>=nb(x)}

4. Construct nondeterministic push down automata that accepts the following languages on ∑ = {a, b}.(i) L= { anb2n : n≥1 }(ii) L= {W: na(w) = nb(w+1) }(iii) L= { anbmcp : p=m+n, m,n,p≥1}(iv) L= { anbmcp : p>m+n, m,n,p≥1}(v) L= { anbmcp : p<m+n, m,n,p≥1}(vi) L= { anbmcmdn : m,n,≥1} L = {w : na(w) = nb(w+1)}(vii) L = {w : na(w) <= nb(w)}

5. Construct a PDA corresponding to the following grammar:(a) S→ aAA, A → aS|bS|a(b) S→ aSbb|aab

Page 4: Question bank toafl

Shivalik College of EngineeringQuestion Bank

Subject: Theory of Automata &

Formal Languages

Course Code: TCS-403

Branch: CSE Semester: IV

(c) S→aSb|A, A→bSa|S|ԑ

Unit – V

1. (a)Design a TM which accepts all strings of the form anbn for n>=1 and rejects all other strings?(b)Design a TM to check whether a string over {a b} contains equal no of a’s and b’s?(c)Design a TM to increment a binary number by 1?(d)Design a Turing Machine that accepts the language L over an alphabet {a, b}* that consists of all strings with an even number of a’s and even number of b’s.

2. Explain the following(i) Universal Turing machine (ii) Church’s Hypothesis(iii) Recursive function theory(iv) Recursive and Recursively Enumerable language(v) Properties of RL & REL.(vi) Unsolvable Decision Problems(vii) Post Correspondence Problem(viii) Halting problem of Turing Machine.

3. Prove the following. (i) If L is a recursive language over Σ show that L’ (L’ defined as Σ – L ) is also recursive(ii) If L and L’ (compliment of L) are both recursively enumerable. Show that L and L’ are recursive.(iii) The Union of two Recursively Enumerable languages is Recursively Enumerable and union of two

Recursive languages is Recursive.4. Define Turing Machine and Universal Turing Machine using suitable diagrams. Explain the language

acceptability by turing machine in short. What are the steps to construct a type-0 grammar generating the set accepted by a given Turing Machine.

5. Give the complete hierarchy of Grammar with their recognizers as well as the form of production rules?