You are on page 1of 13

University of Illinois at Urbana-Champaign

Department of Computer Science

Mock Midterm 1
CS 373: Formal Models of Computation
Fall 2009

Name:
Netid:

• Print your name and netid, neatly in the space provided above; print your name at the upper
right corner of every page. Please print legibly.

• This is a closed book exam. No notes, books, dictionaries, calculators, or laptops are permitted.

• You are free to cite and use any theorems from class or homeworks without having to prove
them again.

• Write your answers in the space provided for the corresponding problem. Let us know if you
need more paper.

• Suggestions: Read through the entire exam first before starting work. Do not spend too much
time on any single problem. If you get stuck, move on to something else and come back later.

• If you run short on time, remember that partial credit will be given.

• If any question is unclear, ask us for clarification.

Question Points Score


Problem 1 20
Problem 2 15
Problem 3 15
Problem 4 15
Problem 5 15
Problem 6 20
Total 100
CS 373 Mock Midterm 1 – Fall 2009 2 Name:

1. Short Problems (20 points)


Give answers to each of the following questions, including a short justification. For each, you
will get two points for the correct answer and two points for the correct justification.

(a) Consider the complement Ac of a nonregular language A. Can we always conclude that
Ac is nonregular? (4 points)
(b) Is it true that every subset of a regular language is regular? (4 points)
(c) Is {0500n 1500n | n ≥ 0} a regular language? (4 points)
(d) If r and s are regular expressions, then does (r ∪ s)∗ = r∗ ∪ s∗ ∪ (rs)∗ hold? (4 points)
(e) Given a DFA M of size n (the number of states) that accepts some string of length at
least n, is it possible for L(M ) to be fininte? (4 points)
CS 373 Mock Midterm 1 – Fall 2009 3 Name:
CS 373 Mock Midterm 1 – Fall 2009 4 Name:

2. Self-Loopless DFA (15 points)


A DFA (Q, Σ, δ, q0 , F ) is called self-loopless if δ(q, a) 6= q for all q ∈ Q and a ∈ Σ. Prove that
a language is regular if and only if there exists a self-loopless DFA that recognizes it.
CS 373 Mock Midterm 1 – Fall 2009 5 Name:
CS 373 Mock Midterm 1 – Fall 2009 6 Name:

3. Subset Construction (15 points)


Convert the following NFA into an equivalent DFA.

q1
a

q0 q2
b
CS 373 Mock Midterm 1 – Fall 2009 7 Name:
CS 373 Mock Midterm 1 – Fall 2009 8 Name:

4. Regular vs. Nonregular (15 points)


n n
Consider the language A = {02 | n ≥ 0} for Σ = {0, 1}. Here, 02 means a string of 2n 0s.
Determine whether or not A is regular and prove your answer.
CS 373 Mock Midterm 1 – Fall 2009 9 Name:
CS 373 Mock Midterm 1 – Fall 2009 10 Name:

5. DFA Minimization (15 points)


Minimize the following DFA by finding the smallest possible DFA that recognizes the same
language. Show your work.

0,1
1

q5
q1

0 1

0,1
1

0
q0 q3 q4

0 1

0
q2
CS 373 Mock Midterm 1 – Fall 2009 11 Name:
CS 373 Mock Midterm 1 – Fall 2009 12 Name:

6. Preserving Regularity (20 points)


Let A and B be two regular languages, and define:

I(A, B) = {w ∈ Σ∗ | a1 , a2 , . . . , a2k ∈ Σ, ∀i a2i+1 ∈ A, a2i ∈ B, and w = a1 a2 a3 . . . a2k }

Prove that I(A, B) is regular.


CS 373 Mock Midterm 1 – Fall 2009 13 Name:

You might also like