Exam C
CS 254, Spring 2013
There are ve problems on this exam.
You have 150 minutes. Notes, calculator, computer, etc. are not allowed.
Your solutions should be rigorous and self-explanatory. A typical classmate should be able to
understand your solutions
Exam B Solutions
CS 254, Spring 2012
A. Suppose for the sake of contradiction that A is context-free. Then, by the pumping lemma
for context-free languages, there exists a pumping length p. Let w = 1p 01p #1p 10p . This w is a
string in A of length at lea
Exam A Solutions
CS 254, Spring 2013
A. A. Let D = 0 1 2 3 4 5 6 7 8 9. Let
Z = DDDDD DDDDDDDDD.
B. Let A be a regular expression that matches all single upper-case letters, lower-case letters,
and spaces
. Let
S = DD
AA .
C. Let
P = PO
Box
DD .
D. Let C
Exam A Solutions
CS 254, Spring 2014
A. Let A = cfw_am bn cn : m 0, n 0. Then A is a CFL, generated by the CFG
S DE,
D |aD,
E |bEc.
Similarly, B = cfw_an bn cm : m 0, n 0 is a CFL. Their intersection is AB = cfw_an bn cn : n 0,
which is not a CFL, as weve
Exam B Solutions
CS 254, Spring 2013
A. Suppose (for the sake of contradiction) that A is context-free. Let p be the pumping
length of A, and let w be the string
1p 0p = 1p 0p 1.
Then w A and |w| p, so the pumping lemma implies that w = uvxyz, where vy =
Exam C Solutions
CS 254, Fall 2013
A. [Strangely, Problem 8.4 omits this operation.] Yes, P SP ACE is closed under concatenation.
Let A, B P SP ACE. Let M, N be deciders for A, B that use space O(nk ), O(n ). Dene a
Turing machine R that, on input w, trie
Exam D Solutions
CS 254, Fall 2013
A. [Although you are not required to justify answers, I justy mine, for educational value.]
A.A. TRUE. [Using the product construction, you can build a PDA that simulates a PDA
and a DFA at the same time, with nal states
Exam B Solutions
CS 254, Spring 2014
A1. The part of my Python regular expression responsible for matching string literals changes
from [^]* to (?:\|[^])*. That is, the characters within a string literal are either (A)
\ combinations or (B) non- character
Exam C
CS 254, Spring 2013
A. We will reduce EMPTYTM to A. Suppose, for the sake of contradiction, that A is decided
by a Turing machine D. Dene a Turing machine C that, on input M , where M is a Turing
machine:
1. Builds a CFG G, over the same alphabet a
Exam B Solutions
CS 254, Fall 2013
A. [Although no justication is required, I give justication, for educational purposes.]
1. TRUE. [This was a homework problem 3.15, I think.]
2. TRUE. [If A is nite, then A is decidable, so A is decidable.]
3. TRUE. [A d
Exam A Solutions
CS 254, Spring 2012
A. Assume for the sake of contradiction that A is regular. Then by the pumping lemma there
exists a pumping length p, such that for the string bp ap+1 A, there exist strings x, y, z
satisfying bp ap+1 = xyz, |xy| p, |y
Exam A Solutions
CS 254, Fall 2013
A. Let A be the empty set and C the set of all strings over cfw_0, 1. These languages are matched
by the regular expressions and (0 1) , and hence are regular. Let B = cfw_0n 1n : n 0, which
is not regular, as weve discu
Exam C
CS 254, Fall 2013
This exam begins for you when you open (or peek inside) this packet. It ends at 9:50 AM on
Wednesday 2013 November 20. Between those two times, you may work on the exam as much
as you like. Although I do not intend the exam to req
Exam B
CS 254, Spring 2013
This exam begins for you when you open (or peek inside) this packet. It ends at 8:30 AM
on Monday 2013 May 20. Between those two times, you may work on it as much as you like. I
recommend that you get started early and work ofte
Exam B
CS 254, Spring 2014
This exam begins for you when you open (or peek inside) this packet. It ends at 9:50 AM
on Monday 2014 May 19. Between those two times, you may work on the exam as much as
you like. Although I do not intend the exam to require m
Exam A
CS 254, Spring 2012
You have 70 minutes.
When drawing an automaton, adopt the following convention, to reduce clutter: If there is no
transition out of a given state for a given input or stack symbol, then the machine rejects the
input string, when
Exam A
CS 254, Spring 2014
This exam consists of four problems spread over six pages (including this page).
Notes, book, etc. are not allowed.
Except where otherwise noted, you should always justify your answers. Correct answers with no
justication may re
Exam A
CS 254, Spring 2013
This exam consists of one cover page and ve pages of problems.
You have 70 minutes. Notes, calculator, computer, etc. are not allowed.
When drawing an automaton, adopt the following convention to reduce clutter: If there is no
t
Exam A
CS 254, Fall 2013
This exam begins for you when you open (or peek inside) this packet. It ends at 9:40 AM
on Friday 2013 October 11. Between those two times, you may work on the exam as much as
you like. Although I do not intend the exam to require
Exam 2
CS 254, Spring 2012
This exam begins for you when you open (or peek inside) this packet. It ends at 12:00 noon
on Monday 2012 May 14. Between those two times, you may work on it as much as you like. I
recommend that you get started early and work o
Exam C Solutions
CS 254, Spring 2012
A. Let A, B P. Let M , N be deterministic Turing machines that decide A, B in time
O(nk ), O(n ), respectively. Dene a Turing machine K that, on input w = w1 wn , does the
following.
1. For i = 0, . . . , n:
(a) K runs