WA1 - 3. Consider the following deterministic finite...

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

View Full Document Right Arrow Icon
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, finite 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 office 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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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. 4. Let L be the language over the alphabet { a 1 ,a 2 ,a 3 } defined 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 finite automaton (NFA) for L . Fall 2009/2010 page 1 of 2 CS 143 Compilers Handout 2 5. For each of the following specifications 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) Specification 1: [aA] { printf ("x"); } [aA][aA] { printf ("y"); } [bB] { printf ("z"); } (b) Specification 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 finite...

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

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