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
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
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 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
For Thursday 27 Jan
Homework #3
Turing Machines
1. Use the web to find a reasonable Turing machine simulator. Use the Turing machine
simulator that you have located to simulate several Turing machine programs.
Start with some easy problems, for exa
Hw3
Question 1:
a)
L = cfw_a nblak : k n + l. Given m, we pick w = a mb ma2m with |w| m. Let w = xyz where |xy| m
and |y| 1. Then, y = ak, where l k m. Now, we consider the pumping strings
wi = a m+(i1)kbma2m.
If i 2, then m + (i 1)k > m. So, wi / L. Acco
CS321: Theory of Computation
HW1
Fall 2017
CS 321: Homework #1
Due: Monday Oct 2 at 9am, on Canvas
Homeworks should be typed. You can describe a DFA by giving its transition table (dont
forget to indicate start state and accept states), or by drawing a st
CS321: Theory of Computation
HW2
Fall 2017
CS 321: Homework #2
Due: Monday Oct 9 at 9am, on Canvas
Homeworks should be typed. You can describe a DFA by giving its transition table (dont
forget to indicate start state and accept states), or by drawing a st
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
CS 321
For Thursday Jan 21
Homework #2
1. Consider the following re-write system
RRR
FF
RRF F R.
(a) Show that each string in cfw_ F, R is equivalent to one of the
following 6 strings:
,
R,
RR,
F,
F R,
F RR,
.
(b) (HINTs: Use induction.
Is every string
CS 321
For Thursday 14 Jan
Hand In at Class
Homework #1
1. This is about Sudoku puzzles. There is an example on the attached
file Sudoku.pdf. This example uses letters but the more common form
uses the digits 1 to 9.
(a) Solve the attached Sudoku puzzle a
CS 321, Fall 2015
Solutions and Grading Scheme for Midterm
October 30, 2015
1. (1 pt) (a) When is an NFA accepting no strings? (b) What is the language of that NFA? Use mathematical notations.
Solution:
(a) w (q0 , w) F = .
(b) .
Grading Scheme:
0.5 pts e
CS 321H
Thursday 4 Feb
Homework #4
Examples of Recognizers / Acceptors / Rejectors
1. Do Ex. 1.9 in the Notes.
2. Show that each of the following sets has a recognizer.
(a) the Prime Numbers
(b) the Fibonacci Numbers
(c) Syntactically correct Pascal progr
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), ) = (
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
CS321: Theory of Computation
HW0
Fall 2017
CS 321: Homework #0
This homework is for review / warmup only. Do these problems to make sure you are
prepared for the course. You may optionally submit solutions, and the TAs & I will gladly
provide feedback.
It
Hw1
Question 1:
=cfw_a,b
L(M)=cfw_ w* | all strings except strings with one b which end to it
Question 2:
a)
b)
c)
d)
Question 3:
L is a regular language because there is a DFA (example is shown below) that such M that
L=L(M).
Question4:
1. Start with an
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 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 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_