This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 143 Compilers Handout 5 Written Assignment I Solutions 1. Write regular expressions for the following languages over the alphabet Σ = { , 1 } : (a) All strings that do not end with 00. + 0 + 1 + (0 + 1) * (01 + 10 + 11) (b) All strings that contain an even number of 1’s. * (10 * 10 * ) * (c) All strings which do not contain the substring 10. * 1 * 2. Draw DFA’s for each of the languages from question 1. (a) q0 1 q1 1 q2 1 (b) q0 q1 1 1 (c) q0 q1 1 1 q2 0,1 Common mistake: Many people gave an NFA instead of a DFA for (c). Fall 2009/2010 page 1 of 3 CS 143 Compilers Handout 5 3. Consider the following deterministic finite automaton (DFA) over the alphabet Σ = { , 1 } . 1 1 0, 1 1 0, 1 Give a onesentence description of the language recognized by the DFA. Write a regular expression for this language. Solution: • All strings that contain two consecutive 0s or two consecutive 1s. • (0 + 1) * (00 + 11)(0 + 1) * 4. Let L be the language over the alphabet { a 1 ,a 2 ,a 3 } defined as:...
View
Full Document
 '09
 Common mistake, Regular expression, finite automaton

Click to edit the document details