CS321
Theory of Computation
Quiz 6, Fall 2013
Name:
1. For each of the following grammars, describe the corresponding language in set notation. In all cases, S, A, B denote variable symbols
and a, b denote terminal symbols, and S is the start variable.
(a
CS321
Theory of Computation
Quiz 3
Name:
1. [10pt] Consider the following NFA N with alphabet = cfw_a, b.
Start
a
q0
q1
q2
b
q3
a
Use either the procedure taught in class or in the book to construct a
DFA M such that L(M ) = L(N ).
Start
Q0,3
a
Q1,2,3
b
b
Homework 5 Solutions
CS 321
4.3 problem 4c
We want to show that the following language is not regular.
L = cfw_an bl ak | n = l or l = k
As usual we start by assuming that the language is regular for the sake of
contradiction. We now need to pick some str
CS321
Theory of Computation
Quiz 2, Fall 2013
Name:
1. Consider the following NFA N ,
q0
q3
a
a
q4
b
q2
q1
b
q5
a
q6
(a) [5pt] Circle the strings from the following list that are accepted
by N .
abba
aab
aaaa
b
(b) [5pt] Let be the transition function for
CS321
Theory of Computation
Quiz 5, Fall 2013
Name:
1. [10pt] Use the Pumping Lemma to directly prove that the language
L = cfw_ai bj ak : i j, k > 0
is not regular.
Solution: Assume that L is regular for the sake of contradiction. This
means that the pum
CS321
Theory of Computation
Quiz 1, Fall 2013
Name:
1. Consider the following DFA M ,
b
b
q0
a
q1
a
q2
a, b
(a) [5pt] Circle the strings from the following list that are accepted
by M .
Reject
bb Reject
ba Accept
aabaa Accept
baaba Reject
(b) [5pt] Let b
Midterm Exam - Theory of Computation
CS 321
July 17, 2014
Name:
Read all of the following information before starting the exam:
Dont forget to write your name.
Show all your work, clearly and in order, if you want to get full credit. I reserve the right
Homework 1 Solutions
CS 321
1.2.6
Let L be any language on a non-empty alphabet. Show that L and L cannot
both be nite.
There are two possible cases: 1) when L is innite, and 2) when L is nite.
The rst case is trivial since if L is innite then it is by de
Homework 3 Solutions
October 24, 2013
Problem 2.3.1
Since no alphabet was specied we will perform the construction for both the
alphabet = cfw_a and alphabet = cfw_a, b.
For = cfw_a we get,
Start
a
S0
S012
a
where S0 = cfw_q0 and S012 = cfw_q0 , q1 , q2
CS 321
Solutions to Homework 4
1. Convert the following NFAs from HW3 to DFA:
(a) cfw_ab, aba
(b) bitstrings with 0 as the third last symbol
(c) bitstrings that contain 0100
How do these converted DFAs compare to your own DFAs in HW3?
Solution:
(a) NFA:
c
CS 321
Solutions to Homework 8
Due November 21, 5pm
Part I: CFG questions
Note that the only way to prove the ambiguity of grammar is to draw two parse trees for the same
sentence.
1. For this grammar in Quiz 6,
E E + E|E E|a|b|c
there are the two types o
10/7/2015
CS 321 Fall 2014 HW2 - DFAs
CS 321 Fall 2014 HW2 - DFAs
1. How do you know if a DFA M:
(a) accepts the empty string
Solution:
.
(b) recognizes the empty language
Solution:
,
.
(c) accepts some (i.e., at least one) string
Solution:
s.t.
.
2. We d
CS 321
Solutions to Homework 5
Due October 28, 5pm
1. Prove that there is one unique partition of states into equivalence classes in DFA, where in each class
A, all states p in A are equivalent, but across any two classes A and B, any state p from A is no
1st Recitation
CS 321 Theory of Computation
Dezhong Deng
http:/classes.engr.oregonstate.edu/eecs/fall2015/cs321/schedule.html
two more questions: 1) decimal numbers divisible by 4
2) all bit strings that contain 10111
0,
hint: you can use 3
states to solv
CS 321
Homework 6
Nov 3, 2015
1. Are the following languages regular? Prove your results.
(a) same number of 0s and 1s
Solution:
For pumping based method please refer page 80 example 1.74 on Sipsers text book.
Here we oer another easier solution :
Assume
CS 321
Homework 7
Nov 12, 2015
1. Write down the definitions of the following levels of ambiguity:
(a) ambiguous string
(b) ambiguous grammar
(c) ambiguous language
Now
(d)
(e)
(f)
(g)
(h)
(i)
(j)
(k)
answer the following (justify your answer):
does an am
Homework 7 CS 321 Due Date: 12/3/10, 2 PM Note: The homeworks should be your own work. You can discuss the homeworks orally with your peers, however. You should not use any web sources for this assignment. Please see the TA and the instructor during the o
Homework 5 CS 321 Due Date: 11/10/10, 2 PM Note: The homeworks should be your own work. You can discuss the homeworks orally with your peers, however. You should not use any web sources for this assignment. Please see the TA and the instructor during the
Homework 1 CS 321 Due Date: 10/6/10, 2 PM Note: The homeworks should be your own work. You can discuss the homeworks orally with your peers, however. You are allowed to use the internet sources only when you are explicitly asked to do so. In such cases, y
Homework 2 Solutions
CS 321
2.2.6
(q0 , 1010) = cfw_q0 , q2
(q1 , 00) =
2.2.7
L = cfw_ababn : n 0 cfw_aban : n 0
Start
a
q0
q1
a
b
q2
q3
a
q4
b
1
Start
q0
q1
b
a
2.2.10(a)
Find an nfa with three states that accepts the language
L = cfw_ an : n 1 cfw_
Homework 4 Solutions
CS 321
3.2.4b
Construct a DFA for L(ab(a + ab) (a + aa).
We will do this by rst constructing an NFA for the language shown below, and
then converting it to an equivalent DFA.
DFA:
a,
q0
a
b
q1
a
q2
q3
b
a
q4
q5
a
Q23456
a
Equivalent
Homework 6 Solutions:
5.1.7(b)
L = cfw_an bm : n = m 1
We can construct grammars for two languages:
L1 = cfw_an bm : n > m 1
L2 = cfw_an bm : n < m 1
Then we can create a new grammar that is the union of L1 and L2 , which equals L.
The following rules all
Homework 6 Solutions:
5.1.7(b)
L = cfw_an bm : n 6= m 1
We can construct grammars for two languages:
L1 = cfw_an bm : n > m 1
L2 = cfw_an bm : n < m 1
Then we can create a new grammar that is the union of L1 and L2 , which equals L.
The following rules al
CS 321 Exam 1 Info
CS 321 Exam 1 - Thursday 2/2
Bring one double-sided notesheet
Sections: 1.1, 1.2, 2.1, 2.2, 2.3, 3.1, 3.2, 3.3, 4.1, 4.2, 4.3
Practice problems from the textbook some have solutions in the back.
2.1: 2, 7 a) d), 9 a) d), 13, 17
2.2: 8,
CS 321
Homework 3
October 9, 2015
1. For any DFA, prove that is associative; that is for any input strings x and y, (q, xy) = ( (q, x), y).
Solution:
Do induction by the length of y.
Base case y = and |y| = 0:
(q, xy) = (q, x) = (q, x ) = ( (q, x), ) = (