WA1-solutions

WA1-solutions - CS 143 Compilers Handout 5 Written...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 1s. * (10 * 10 * ) * (c) All strings which do not contain the substring 10. * 1 * 2. Draw DFAs 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 one-sentence 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

Page1 / 3

WA1-solutions - CS 143 Compilers Handout 5 Written...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online