Tanta University Faculty of Engineering Computers and Control Dept Third Year Compilers Theory Second term 2006 Problem Set (2) (1) Describe the language denoted by the following expressions: a) 0(0|1)*0 b) ((|0)1*)* c) (0|1)*0(0|1)(0|1) d) 0*10*10*10* e) (00|11)*((01|10)(00|11)*(01|10)(00|11)*)* (2) regular Write regular definitions for the following languages. a) All strings of letters that contain the five vowels (a, e, i, o, or u) in order. b) All strings of digits with no repeated digit. c) All strings of digits with at most one repeated digit. d) All strings of 0’s and 1’s with an even number of 0’s. e) All strings of 0’s and 1’s with and odd number of 1’s. f) All strings representing odd binary numbers. g) All binary strings that do not begin with 11. h) All strings of 0’s and 1’s that do not contain the substring 011. i) All strings of 0’s and 1’s that do not contain the subsequence 011. j) Comments consisting of string surrounded by /* and */ without an intervening */ unless it appears inside the quotes “ and “. (3) Construct nondeterministic finite automata for the following regular expressions. Show the sequence of moves made by each in processing the input string ababbab. a) (a|b)* b) (a*|b*)* c) ((|a)b*)* d) (a|b)*abb(a|b)* (4) Construct regular expression corresponding to the following finite automata. (5) Convert the NFA’s in problem 3 into DFA’s. Show the sequence of moves made by each in processing the string ababbab. (6) Give an NFA with 4 states which accepts the language (01, 011, 0111). Use the subset construction to obtain an equivalent DFA. (7) We can prove that two regular expressions are equivalent by showing that their minimum–state DFA’s are the same, except for the state names. Using this technique, show that the following regular expressions are all equivalent. a) (a|b)* b) (a*|b*)* c) ((|a)b*)* (8) Convert the following nondeterministic finite automaton into a deterministic finite automaton step-by-step using the subset construction algorithm, where state 0 is the initial state and state 3 is a final state. State/Input 0 1 2 3 a b {2} {2} {1,3} {1,3} (9) Construct parse tree, NFA, and minimum DFA for the following regular expressions: a) (ab|c)* b) c(ba)*|)* c) z*|(wx))*(xy) d) x(z*|(w*x)|)y e) 10|(0|11)0*1 (10) Construct a minimized DFA and transition table for the DFA below. b C b start A a B b b D a a b a E