# SHAHEED UDHAM SINGH COLLEGE OF ENGINEERING AND TECHNOLOGY , TANGORI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK

Subject Code: CS-404 Subject Name: FLAT Prepared By: - Er. Sukhpreet Kaur Year/ Sem: 4th / 7th

1) 2) 3) 4) 5) 6) 7) What is the difference between Kleene’s closure and Positive closure of a set? What is a Finite Automaton? The Regular Sets are closed under Homomorphism. Explain. Explain Homomorphism and Inverse Homomorphism. What are Ambiguous Grammars? Is Push Down Automata a Deterministic Device? Explain. What is the difference between Regular Grammar and Context Free Grammars? 8) If F1 and F2 be two Finite Automata accepting languages L1 and L2 respectively, when can F1 and F2 be termed as equivalent? 9) Can the language {anbncn : n>=0 } be accepted by a Turing Machine. 10) State any two properties of LR(k) grammars. 11) What do you mean by reduced grammars? Give example. 12) Every non-empty CFL is generated by a CFG with no useless symbols. Justify the statement. 13) Give the leftmost order of derivation of a string id + id * id. Also draw the derivation tree with the grammar E  E+E | E*E | id. 14) What do you understand by Recursively Enumerable Language? 15) State about Dyck Language. 16) Define Regular Expressions. 17) What do you understand by Canonical Derivations? 18) Differentiate between Context Free and Context Sensitive Grammars. 19) The conversion from a grammar to Chomsky normal form can square the number of productions in a grammar. Justify the statement. 20) Write the definition of a Language and give an example. 21) Give the difference between Type 1 grammars and Type 2 grammars. 22) Write the One Sided Context Sensitive Grammar. 23) Give the mathematical definition of Finite Automata. 24) Write the Kuroda Normal Form. 25) Explain in detail the properties of LL(k) grammars. 26) Give the transition table of a Turing Machine. 27) Write algebraic properties of Universality.

A  bS .b} is an example of Dyck Language….Push Down Automata? 49) Construct a nondeterministic finite automaton accepting {ab. A  aAB | a . 44) What is Idempotence Law of Union? 45) What is meant by Yield of a Parse Tree ? 46) Give formal notation for Push Down Automata. What is L* and L+? 51) What is the difference between NDFA and DFA? 52) Differentiate between PDA and 2PDA. .ba}. 36) Find the language generated by the following grammar S  0S1 | 0A1 . True/False 29) A grammar given by A aS | b | aSS | a is in GNF. True/False 34) What are Rewriting Systems? What are the two operations in Rewriting Systems? 35) Prove that the following grammar is ambiguous :S  aB | ab .. b but have exactly one ’a’. and use it to find a deterministic automaton accepting the same set. 37) Construct a C. 1}. it signifies that the problem cannot be enumerated by a Push Down Automata…. 47) What are useless symbols in context of grammars? 48) What is 2. True/False 39) A language that is accepted by a Push Down Automaton must always have a grammar to generate the same language set….G generating all integers ( with sign) 38) Cellular automaton can be made to work in any dimension of adjacency…. A  1A | 1. True/False 33) A set of palindromes over the set {a. 55) Prove that the following grammar is ambiguous :S  aB | ab . True/False 41) C compiler is an example of one sided context sensitive grammar…. 50) Consider a set L = {0. SΛ. b) which uses character a . True/False 40) LL(1) grammars are never ambiguous…. A  aAB | a .E for the following language: a) which uses first character ‘a’ or ‘c’ followed by any string using ‘b’.28) For a given problem if a Turing machine halts. True/False. True/False 42) What is ε –closure of state? 43) Write regular expression for the language which consists of set of strings of 0's and 1's with atmost one pair of consecutive 1's.F. 53) What are Rewriting Systems? What are the two operations in Rewriting Systems? 54) Give the R. 30) Finite Automata can have a single bit memory to remember a past state in which it has been at earlier time… True/False 31) Homomorphism is property of regular languages but not of context free languages…. 56) Find the language generated by the following grammar S  aA . B  ABb | b. B  ABb | b. True/False 32) Derivation languages must be Context sensitive languages….

57) Design a CFG for the language :L = { 0n 1n | n>=0} U { 1n 0n | n>=0} 58) State and prove Arden’s Theorem. 60) Find the grammar for the following language : L = { an b2n cm | n.e = (b * (aaa) * b *)* 75) Show that (0*1*)* = ( 0 + 1)* 76) Construct CFG for the language containing atleast one occurrence of double a. 70) Construct the regular expression for the language accepting all the strings which are ending with 00 over the set Σ = {0. 69) Design the regular expression for the language accepting all combinations of a’s except the null string over Σ ={a}. 81) Design FA which accepts only those strings which start with 1 and ends with 0. 59) Find the language generated by the following grammar S 0S1 | 0A | 0 | 1B | 1 . 66) Differentiate between Derivation Trees and Derivation Graphs. 64) Give the regular expression for the set of strings of 0’s and 1’s whose tenth symbol from the right end is 1.1}. 71) If L = { The Language starting and ending with a and having any combination of b’s in between}.c) containing at least one a and at least one b. 74) Describe the language denoted by following regular expression r. 63) Write the regular expression over alphabet (a. B 1B 1. 62) Differentiate between Homomorphism and Isomorphism. 67) What are Derivation Languages? State the algebraic properties of derivation languages with suitable example.m>=0} 61) Consider the CFG SXX. 67) Define Parse Trees ? What is meant by a yield of a parse tree? 68) Write the regular expression for the language accepting all combinations of a’s over the set Σ = {a}. 78) Design a FA which accepts the only input 101 over the input set Z = {0. 79) Why finite automata are less powerful than PDA? 80) Design a FA which checks whether the given binary number is even. then what is r? 72) Describe in simple English the language represented by the following regular expression r = (a +ab)* 73) Write a regular expression which denotes a language L over the set Σ = {1} having odd length of strings. 65) Write a regular expression for the set of strings of 0’s and 1’s not containing 101 as a substring. . 77) Construct CFG for the language containing all the strings of different first and last symbols over Σ = {0.1}.1). A  0A | 0 .b. X XXX | bX | Xb | a Find the parse tree for the string bbaaaab.

b} . 6) Why is it necessary to have unambiguous grammar? Consider the grammar given by SaS | aSbS | ε. B  ab . Aa . 7) Discuss the working of cellular automata with a suitable example. C}. . P1 . B  0BB | 1S | 1 4) Prove that the language of a set of strings of 0’s and 1’s whose length is a perfect square is not regular. B. q .b}. 5) a) State differences between a push down automata and a 2 push down automata. 2) Show that G1 = ( { S} . A}. e. {a. C  aBC | ad. A  1AA | 0S | 0 . 8) Construct a NPDA equivalent to the following grammar: G = ( {S.δ . ε ) } Convert this PDA to an equivalent grammar. P2 .Long Answer/Comprehensive Type Questions 1) Find the reduced grammar that is equivalent to CFG given below S  aAa . S ) Productions S -> a A A A -> a S | b S | a 9) Find the reduced grammar that is equivalent to CFG given below : S  aC | SB. {e. Z) where δ is defined by : δ ( q . {a . {a . B  aSB | bBC. 15) Draw a parse tree for the following grammar which derives the string 00011 S  A1B A  0A/ ε B  oB/1B/ε 16) Consider the following ambiguous grammar. Z ) = { ( q. A  bSCa. i . 14) Prove that {0"/n is a power of 2} is not a regular language. C SB .i}. where P1 = { S  aSb | ab } is equivalent to G2 =( {S . where P2 = { S AC . Z ) = { ( q. 13) Explain Translation Lemmas in complexity theory. S AB . Bb} 3) Convert the following grammar into CNF. 10) Construct the Finite Automata for accepting all possible strings of zeros and one’s which does not contain 011 as substring. 11) List and explain various formal language aspects in detail. b) Consider the following Push Down Automata P = ({q}.ZZ)} δ ( q . S ) . S  as/aSbS/ ε. A  bBB . b}. A . Prove that this grammar is unambiguous. S ). S  1A | 0B . C aB. P. 12) List the properties of context free grammars/languages. {Z}.

28)Find the reduced grammar that is equivalent to CFG given below : S  aAa . SbSb . 24) Write the definition of a non deterministic push down Automata (npda). T={a.b}. 25) Convert the following grammar with productions SABa. P ={ SaSa . P1 . B. b} .T.b}* and wR is reverse of string w}. C}. where P2 = { S AC .c}.e. 23) Convert the grammar SAS | aa into GNF. C  abb |DD . 31) Identify and remove the unit productions from following grammar S A | bb. L = { 0i1i | i is an integer. Aa . Construct a pda A accepting L={ wcwT | w belongs to {a.P. {a . Explain the statement with a suitable example. where P1 = { S  aSb | ab } is equivalent to G2 =( {S .Show that the string ‘aab’ has two : (i) Parse Trees (ii) Left Most Derivation (iii) Right Most Derivations 17) Write a brief note about Universality and Complexity in cellular automata. 27) If X and Y are regular sets over ∑. i>=1} Prove that L is not a regular set.b}* } by final state.S) with V ={S}. A. Construct a PDA equivalent to the following grammar. S ). Sc} where generates the language {wcwR : w t {a. Bb} 30) Convert the following grammar into CNF. {a . BAc to Chomsky Normal Form. P. 18) Give the Deterministic Finite Automata accepting the set of all strings of 0’s and 1’s in which both the number of 0’s and 1’s are even. P2 . . A . b}. C}. S) with Productions S -> AB | BC A -> BA | a B -> CC | b C -> AB | a Determine if these strings are in the language: a) aaaaa b) aaaaaa c) baabab 22) Some languages which are not accepted either by a Finite Automaton or by a Push Down Automaton are accepted by a Turing Machine. D  aDA 29)Show that G1 = ( { S} . then X ∩ Y is also regular over ∑. {a. B. 20) Let G be a grammar given by (V. S AB . Aaab. 19) Let L be the set of all strings given by 0i1i where i is an integer greater than 1 i. 21) Given the CFG G = ( {S. 26) Show that L ={anbncn | n>=1} is not context free but context sensitive.b. C SB . S abSb | a | aAb A  bS | aAAb. E  aC . S ) . A  Sb | bcc | DaA .

34) For the ∑ = {a. which can generate string. b. where Σ = {a.b} i) Build an FA that accepts only those words that have more than four letters. All strings that have an even number of a’s and an odd number of b’s. d. 41) Write out the steps using the pumping lemma for CFL's to prove that L = { aibici | i >= 1 } is not a CFL.c} in which every string will be such that any number of a’s is followed by any number of b’s is followed by any number of c’s. All strings that have an odd number of a’s and an odd number of b’s. having any combination of a’s and b’s except null string. 46) a) Write regular expression to denote the language L over Σ*. 40) Let G be a CFG in Chomsky Normal Form. iv) Build an FA that accepts only those words that do not with ba. iii) Build an FA that accepts only those words with exactly four letters.c} such that every string will have atleast one a followed by atleast one followed by atleast one c. 35) Construct a finite automata for the regular expression r = (a + b)* abb. All strings in which a is tripled or b is tripled. All strings that do not end in a double letter. .A  B | b. b) Write a regular expression to denote a language L over Σ*. ii) Build an FA that accepts only those words that have fewer than four letters. 47) Write a regular expression to denote a language L which accepts all the strinsg which begin or end with either 00 or 11.b} a. B  S | a. 45) Build a Turing Machine that accepts the language of all words that contain the substring bbb.b. Give an algorithm to determine the number of distinct derivations of a string x. All strings in which letter b never triples. 37) Prove that language which contains set of strings of balanced parentheses is not regular. AbSCa . BaSB | bBC. CaBC | ad. C  c. e. v) Build an FA that accepts only those words that begin or end with a double letter. 38) Write a CFG which generates strings having equal number of a’s and b’s. where Σ = {a. 32) Consider the following grammar G and remove the null productions : SABAC . 42) How do we eliminate empty moves from any NDFA? 43) What are the various identities for the regular expressions? 44) Construct a regular expression defining each of the following language over the alphabet ∑ = { a.b. B bB | Λ . c. A aA | Λ . 39) Design a CFG. 33) Find the reduced grammar that is equivalent to the CFG given below: SaC | SB . 36) Prove the following identity : ( a * ab + ba)*a* = (a+ab+ba)*.

b}. 60) Construct PDA over Σ = {0.for the language consisting strings of twice as many a’s as b’s. 49) Show that ( ab )* is not equal to (a*b*) 50) Show that (r+s)* is not equal to r* + s* 51) Prove that r(s+t) = rs + rt 52) Find whether (a*ab + ba)*a* = (a+ab+ba)* 53) Construct a grammar for the language containing strings of at least two a’s. then prove that there is context free grammar G with L(G) = L 3) What is the significance of converting a grammar to GNF? Convert the following grammar to GNF S ASB | ε A aAS | a B  SbS | A | bb 4) a) Turing machines are simplified representation of a general computer. 61) Construct NFA for the regular expression b + ba* 62) Design a FA from given regular expression 10 + (0 + 11) 0*1. concatenation and transpose. 56) Recognize the context free language for the given CFG S  aB | bA A  a | aS | bAA B  b | bS | aBB 57) Design FA which accepts odd number of 1’s and any number of 0’s.b}. the strings may or may not have consecutive a’s.1}. 58) Design FA which checks whether the given unary number is divisible by 3. 59) Compare push down automata with finite automata. c) Construct regular expression for the language which consists of exactly two b’s over the set Σ = {a. e) Construct a regular expression which denotes a language L over the set Σ = {0} having even length of string. Explain b) Design a Turing Machine to accept the language L of palindromes over . where Σ = {a. 55)Construct CFG for the language in which there are no consecutive b’s. b) Construct a regular expression for the language L which accepts all the strings with atleast two b’s over the Σ = {a.b} such that the third character from right end of the string is always a. 2) Let M be a push down automata accepting a language L by empty stack.48) a) Write a regular expression to denote a language L over Σ*. d) Write a regular expression which contains L having strings which should have atleast one 0 and atleast one 1. 54) Construct a grammar which consists of all the strings having atleast one occurrence of 000. Very Long Answer/Application Based Questions 1) Prove that how all the languages classified by the Chomsky are closed under union.

how to prove that they are equal. 22) Identify and remove the unit productions from following grammar S A | bb. 12) Design a Turing Machines which generates a set of string with equal numbers of 0's and 1's. L is recognized by a Turing machine. 6) Consider the grammar: S A . n on the input is just n zeros followed by blank tape. What essential feature does a Turing machine have that a NPDA did not have to be able to recognize L ? 11) Prove that for any CFG G there is a CFG G1 in Chomsky Normal Form such that L(Gl) = L(G) where L is the language accepted by the grammar. 18) We can use Pumping Lemma to prove a language is not regular by contradiction. B  S | a. 7) Write the machine description for a Turing machine. including delta transition table for the specific machine that starts with a number n on the tape and finishes with n squared on the tape. Construct NFA and its equivalent DFA for LR(1) items of above grammar. 9) Construct an NFA for the following regular expression: 10 + (0+11) 0 * 1. 23) Consider the following grammar G and remove the null productions : . 13) Convert the following regular expression to NFA : ( i ) ( 0 + 1 )1 ( 0 + 1 ) (ii) 00 (0 + 1) (iii) 01* (iv) (0 + 1) 01 14) If L is a context free language. Reduce the following grammar into GNF : S  A0 . Are there cases when we cannot find a string that cannot be pumped to prove a language is not regular? 19) How do the three constraints of "special form GNFA" definition make sense in the procedure converting DFA to regular expression? 20) The pumping lemma states that all regular languages have a special property. BaB | b. then there exists a PDA M which accepts L.b}. A  B | b. B  A0 . A  0B . A  BA | ε .{a. 16) Given two regular expressions. (tape 000#b) 8) If L is a context free Language. 5) How can you say that Turing Machines are more capable than finite state machines. Prove. 15) Construct an NFA for the following regular expression: 10 + (0+11) 0*1. Explain. Is there any nonregular language having this special property? 21) Discuss in brief Griebach Normal Form. then there exists a PDA M which accepts L. B  1. Prove. or in other words they match exactly the same language? 17) Prove that if L is regular then LT is also regular. 10) L = { ww | w in Sigma star } is not a CFL.

26) Build a Turing Machine that accepts the language ODD PALINDROME. Also prove the following: a) A right – linear or left-linear grammar is equivalent to a regular grammar. concatenation? 36) The state diagram of a TM seems to be tricky.v belongs to terminal set and they are not empty/ Show that a context-free language is regular iff it is generated by a nonselfembedding grammar. 25) Construct the DFA for the regular expression (0+1)*1 (0+1).B. whether B is regular? Or under which circumstance would the conclusion be true? 38) We can construct a CFG for a regular language by constructing a DFA for that language. then L is regular. and C = A concat B. intersection. What kind of CFG can be constructed this way? Do these CFGs have some attributes? Is there a clear way to know whether the language is regular by only the context-free grammars? 39) If we already know some CFG is ambiguous. c) If L* is regular. a) If L1 U L2 is regular and L1 is regular. the number of rules. B bB | Λ . A aA | Λ .SABAC . Are there any tips how to draw the diagram? 37) Let A. complement. b) A linear grammar is not necessarily equivalent to a regular grammar. then L2 is regular. 30) A context free grammar G is said to be self-embedding if there exists some useful variable A such that A can derive uAv.C be languages. m < n. 27) Are the following true or false? Support your answer by giving proofs or counterexamples. 31) Show that a regular set accepted by a deterministic finite automaton with n states is accepted to final state by a deterministic pda with n states and one pushdown symbol. AbSCa . 28) a) Construct a regular grammar which can generate the set of all strings starting with a letter ( A to Z) followed by a string of letters or digits ( 0 to 9). is there some algorithm to eliminate the ambiguity? 40) If two DFAs M1 and M2 have been transformed to their minimal forms. then L2 is regular. 29) What are the linear grammars? Explain its various types. how can we easily check whether these two minimal DFAs are isomorphic? 41) Why do Turing recognizable/decidable languages not have a pumping lemma? Is it because they have not enough structure information like CFL and regular language? . b) Show that a deterministic finite automaton with n states accepting a nonempty set accepts a string of length m. Deduce that every regular set is a deterministic context-free language. 32) Why are all regular languages context-free? How can we prove it? 33) What's the difference between the language recognized by deterministic and nondeterministic ones? Can we make a pushdown automaton deterministic? 34) What do you want to minimize. the total length of right-hand sides. where u. If C and A are both regular. BaSB | bBC. C  c. CaBC | ad. the maximum length of right-hand side? 35) Are Context Free Languages closed under union. 24) Find the reduced grammar that is equivalent to the CFG given below: SaC | SB . b) If L1L2 is regular and L1 is regular.

b) Design NFA which accepts the string containing either ‘01’ or ‘10’ over Σ = {0. a) Draw the state transition diagram. DFA. q0. design a Deterministic Finite Automata. sigma. 1} that contain three consecutive ones. 48) Design DFA for accepting the set of integers.1}. 3) The set of strings over sigma={ a.1 } in which every string start with 0 and ends with 1. b) Design FA which checks whether a given binary number is divisible by three. 1} ending in 11 2) The set of strings over sigma={ 0. b) Write the state transition table. b. F) Q={?} F={?} q0 = ? sigma = { ? } delta = ? transition table ? 45) a) Design FA to check whether given decimal number is divisible by three. q4 } ----+----------+---------q0 | {q0. 44) Convert the NFA to an equivalent DFA | 0 | 1 F = { q2. 46) Construct the transition graph for a FA which accepts a language L over Σ {0.q3} | {q0. one b and one c. Languages: 1) The set of strings over sigma={ 0.1}. delta. 49) a) Construct a NFA in which double ‘1’ is followed by double ‘0’ over Σ = {0. 47) Design a FA that reads strings made up of letters in the word CHARIOT and recognize those strings that contain the word ‘CAT’ as a substring. c) Write a regular expression. c} that contains the empty string and strings that have a length that is a multiple of three with every block of three containing one a.42) Which of the following grammars generates the string \$\$ X  \$ | X\$\$ | \$\$X X \$ | \$\$X | XX\$ X  \$ | \$\$\$ | XX X \$ | \$\$X | X\$X X  \$ | \$X\$ | \$\$X 43) For each language below.q1} q1 | phi | {q2} q2 | {q2} | {q2} q3 | {q4} | phi q4 | {q4} | {q4} M = (Q. .

54) Construct a Turing Machine which accepts the language of aba over Σ = {a. ) .b}. { . 58) a) Construct Turing Machine for reversing a binary string on the input tape. 59) Construct Turing Machine for performing logarithmic operation of given binary number i. Consider the parenthesis is as (. 51) Design pda that checks the well formedness of parenthesis.e. This TM is for a concatenate function. compute log(n) function.b} which will convert lower case letters to upper case. b) Construct Turing Machine for copying the input unary string on the tape. ]. 60) Build a multitrack Turing Machine for checking whether given number is prime or not? . }. 55) Design a Turing Machine which recognizes the input language having a substring as 101 and replaces every occurrence of 101 by 110. 56) Construct Turing Machine for concatenation of the two strings of unary numbers.50) Design push down automata which accepts only odd number of a’s over Σ = {0. 53) Construct a Turing Machine M for Σ = {a.1}. 52) Construct pda for accepting the strings of even-length parenthesis. 57) Construct Turing Machine for obtaining two’s complement of a given binary number. [ .