08.06.2015 Views

Midterm problem set (PDF)

Midterm problem set (PDF)

Midterm problem set (PDF)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Mid-Term 1 Due Fri., 14 Oct.<br />

CMPSC 230<br />

Theory of Computing<br />

Fall 2005<br />

Home page: http://cs.allegheny.edu/~rroos/cs230f2005/<br />

Weblog: http://cs230f2005.blogspot.com<br />

Mid-Term Take-Home Problem Set<br />

All input alphabets are Σ = {a, b} unless otherwise noted.<br />

1. Design an NFA that accepts the language of the regular expression ((ab) ∗ ∪ b ∗ (a ∪ b))(ab ∪ ba)<br />

2. Design a DFA that accepts the same language as the following NFA:<br />

a,b<br />

a<br />

1<br />

a<br />

2<br />

a<br />

b<br />

ε<br />

3<br />

3. Find the regular expression that describes the language accepted by the following DFA:<br />

b<br />

1<br />

a, b<br />

2<br />

a<br />

b<br />

a<br />

4. Let Σ = {u, d, l, r} (“up,” “down,” “left,” “right). Then any string over Σ can be interpreted<br />

as a drawing consisting of a sequence of unit-length line segments drawn in the indicated<br />

direction, where each line starts where the previous line ended. For instance, the strings<br />

urdl, drul, ruld, etc., all represent squares with side length equal to one unit. Since we<br />

can “back up” or retrace a line segment, the following strings also represent unit squares:<br />

udulrldr, ldrlurd, etc. The string uudrdl is not a square — (it has an extra line sticking<br />

up at the top left corner).<br />

Handed out on 7 October 2005 Handout # 5


Due Fri., 14 Oct. 2 Mid-Term<br />

(a) Describe the <strong>set</strong> of all strings over Σ that represent a unit-length line. Is it a regular<br />

language?<br />

(b) Describe the <strong>set</strong> of all strings over Σ that represent the left and bottom sides of a unit<br />

square — in other words, a right-angle with unit sides and the “opening” facing up and<br />

to the right — dr and lu are two examples.<br />

(c) Let L be the <strong>set</strong> of all strings over Σ that represent rectangles of any dimensions. (For<br />

example, lurrdl represents a 2-by-1 rectangle.) Prove that L is not a regular language.<br />

(Hint — you only need to find a single element of L that violates the pumping lemma,<br />

so try to choose one that has a nice form you can use.)<br />

5. We know that every regular language is also a context-free language. For each of the regular<br />

languages described below, construct a context-free grammar that generates the language.<br />

(a) The regular expression: ((a ∪ b)a) ∗ ∪ b ∗ ab ∗<br />

(b) {w | |w| a is a multiple of 3} (assume Σ = {a, b})<br />

(c) The language accepted by<br />

S<br />

a<br />

a<br />

A<br />

b<br />

b<br />

B<br />

b<br />

a<br />

C<br />

a,b<br />

HINT: can you figure out a way to construct the grammar<br />

simply by looking at the transitions in the DFA?<br />

6. Give an informal description of a nondeterministic pushdown machine that accepts the language<br />

of all strings w over {a, b, c} such that either w is of the form ucu r , where u ∈ {a, b} ∗ , or<br />

w is of the form b i c i for some i ≥ 0. You don’t have to draw the state machine, just describe<br />

how it works. Be sure to indicate where the machine needs to make any nondeterministic<br />

choices.<br />

Handout # 5 Handed out on 7 October 2005

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!