# WA1 - 3. Consider the following deterministic ﬁnite...

This preview shows pages 1–2. Sign up to view the full content.

CS 143 Compilers Handout 2 Written Assignment I Due Thursday, October 8, 2009 at 5pm This assignment asks you to prepare written answers to questions on regular languages, ﬁnite au- tomata, and lexical analysis. Each of the questions has a short answer. You may discuss this assignment with other students and work on the problems together. However, your write-up should be your own individual work. Written assignments can be turned in at the start of lecture. Alternatively, assignments can be turned in at Professor Aiken’s oﬃce in Gates 411 by 5:00 PM on the due date. If you are an SCPD student, this assignment can be submitted electronically in PDF format by following the electronic sub- mission instructions at http://www.stanford.edu/class/cs143/policies/submit.html by 5:00 PM on the due date. 1. Write regular expressions for the following languages over the alphabet Σ = { 0 , 1 } : (a) All strings that do not end with 00. (b) All strings that contain an even number of 1’s. (c) All strings which do not contain the substring 10. 2. Draw DFA’s for each of the languages from question 1.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3. Consider the following deterministic ﬁnite 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. 4. Let L be the language over the alphabet { a 1 ,a 2 ,a 3 } deﬁned as: L : All strings in which a i occurs at least i times for some a i with i ∈ { 1 , 2 , 3 } . Draw a non-deterministic ﬁnite automaton (NFA) for L . Fall 2009/2010 page 1 of 2 CS 143 Compilers Handout 2 5. For each of the following speciﬁcations written in Flex, give a regular expression describing the language of possible outputs. Assume that all inputs are strings consisting of characters a, b, A, and B. (a) Speciﬁcation 1: [aA] { printf ("x"); } [aA][aA] { printf ("y"); } [bB] { printf ("z"); } (b) Speciﬁcation 2: ([aA]+)([bB}+) { printf("a"); } [aA] { printf("b"); } [bB] { printf("c"); } Fall 2009/2010 page 2 of 2...
View Full Document

## This note was uploaded on 01/12/2010 for the course CS 143 at Stanford.

### Page1 / 2

WA1 - 3. Consider the following deterministic ﬁnite...

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

View Full Document
Ask a homework question - tutors are online