You are on page 1of 4
Lert 2 3 DEC 2019 Reg.No.:__ Amrita Vishwa Vidyapeetham School of Engineering, Bengaluru Campus B Tech. Degree Examination December 2019 ‘Computer Science and Engineering Fifth Semester 1SCSE303 Theory of Computation ‘Time: Three hours Maximum marks: 100 co ‘Course Outcomes COi_| Understand and apply the properties of formal languages CO2 [illustrate grammar and grammar transformations for formal languages ‘CO3_| Construct finite state machines CO4_| Apply stack data structures for automata [COS~_[Design and develop computing devices such as Turing machines Answer all questions 1 (a) Suppose a restricted version of the Java programming language is defined in which variable names must satisfy all of the following conditions: * A variable name can only use Roman letters (i.e., a, by. 2 Ay By a 2) or Arabic numerals (i.e., 0, 1, 2, 5 9); i., underscore and dollar signs are not allowed. © A variable name must start with a Roman letter: a, by... 2, Ay Be © The length of a variable name must be no greater than 8. * A variable name cannot be a keyword (¢.g., if). The set of keywords is finite. Let L be the set of all valid variable names in this restricted version of Java. Write regular expression for representing the variable names in L. [3] [C03] (b) Write NFA for the language L = {w | = (0, 1} and w contains at least two 0°s, or exactly two I's) with not more than six states. B] [C03] (c) Convert the Non-Deterministic Finite Automata (NFA) given in Figure 1, to Deterministic Finite Automata (DFA). Write the language generated by the DFA. (8) [CO3} R Page 1 of 4 2 (a) Drawa DFA for the language accepting strings ending with ‘abba’ over input alphabet © = {a, b}. GB] [c03) (b) Write Non-Deterministic Finite Automata (NFA) for the regular expression (a+b)(ab)*e using Thompson’s Constructi 21 (co3] (©) Find the minimal Deterministic Finite Automata (DFA) for the given DFA in Figure 2 using Tabulation method. Draw the minimal DFA. [6] [Co3} Figure 2 3 (@) Consider the given finite state machine in Figure 3 and find the language generated in the machine using state reduction method. Write the resulting regular expression for the accepted language. b [5] [C03] Figure 3 (b) Identify the regular and non-regular languages and Justify (i) L={a"b™ | n=0} 1 (Co3] Gi) L= {w | w contains the substring aab and w¢ (a, b}" } (©). Show that the language L is non-regular using pumping lemma. L= {w | w contains an equal number of a’s and b's} 1 (col) R Page 2 of 4 » 4 @)_ Give a Context Free Grammar (CFG) for each of the following languages over the alphabet © = {a,b} (0 All strings in the language L= {a ba2" | n, m> 0} 41 Gi) All non-empty strings that start and end with the same symbol (b) Convert the following CFG into an equivalent CFG in Chomsky Normal Form(CNF). S—BsB| B| A 7 B+00]2 cB 5 (@)_ Consider the following grammar and derive the string w = aaabbabbba using leftmost derivation and rightmost derivation. Draw the corresponding derivation trees. S—aB |bA (5} A—aS |bAA | a B+ bS|aBB] b (b) Describe the language for the following contextfree grammars as concisely as possible. (@) S— aAb|aBb | a A—abbla B—aAb|b (ii) S—+ Aab| Aba | 2 A—+abA | baA | 2 Gil) S aL L—+ab | albj 2 6 —(@) Eliminate left recursion in the grammar below: S—SS|aS |MN M=—Malab BI Nob [a (b) Simplify the following grammar efficiently. S—raAa A— Sb |bCF | Daa 8 C—abb [DD | E 8] E-ac |X D—aDA |i [co2} [co2] (coz) [co2) [co2] [co2} R Page 3 of 4 (a) Write left-linear grammar for the language L = L(abba*bababb*a). 6} [C02 (b) Define Deterministic Push Down Automata (DPDA). Design the PDA for the given language L. bik [8] (COs) L={alb'c*| i,j,k 20, and i=j orj=k} (@) Draw the diagram to depict the Chomsky Hierarchy and show the type of grammars, languages and machines. [4] [con (b) Let M be the PDA defined by M = ({qo, qi, ga}. {a,b}, {A}, qo, A, fais aa}). (qo, 2, 4) = (a1, A) (qo, b, A) = @, 4) 5(q1.A, A) = (qi) (qa, b, A) = (G2, 2) (7 [cos] 8(qa, 2, A) = (qa. 2) (@) Describe the language accepted by M. (ii) Give the state diagram of M. (ii) Trace all computations of the strings ab, abb, aba in M. (@) Design a Turing machine to accept the given language. L=(w0* | we {0,17} {8} [Cos] (b) Describe briefly the types of Turing machines. [4] [cos] Page 4 of 4

You might also like