Docsity

CS 172: Computability and Complexity - Midterm 1 Exam, Spring 2010, Exams of Advanced Algorithms

Toggle sidebar
bg1
CS 172: Computability and Complexity, Spring 2010 S. A. Seshia and O. Etesami
Midterm 1
March 1, 2010
YOUR NAME :
Instructions:
This exam is open-book, open-notes. Please turn off and put away electronic devices such
as cell phones, laptops, etc.
You have a total of 75 minutes. There are 4 questions worth a total of 100 points. The
questions vary in difficulty, so if you get stuck on any question, it might help to leave it and
try another one.
Answer each question in the space provided below the question. If you need more space,
you can use the reverse side of that page. You can use without proof any result proved in
class, in Sipser’s book, or during discussion sections, but clearly state the result you are
using.
Do not turn this page until the instructor tells you to do so!
Problem 1
Problem 2
Problem 3
Problem 4
Total
1
pf3
pf4
pf5

Partial preview of the text

Download CS 172: Computability and Complexity - Midterm 1 Exam, Spring 2010 and more Exams Advanced Algorithms in PDF only on Docsity!

CS 172: Computability and Complexity, Spring 2010 S. A. Seshia and O. Etesami

Midterm 1

March 1, 2010

YOUR NAME:

Instructions:

This exam is open-book, open-notes. Please turn off and put away electronic devices such as cell phones, laptops, etc.

You have a total of 75 minutes. There are 4 questions worth a total of 100 points. The questions vary in difficulty, so if you get stuck on any question, it might help to leave it and try another one.

Answer each question in the space provided below the question. If you need more space, you can use the reverse side of that page. You can use without proof any result proved in class, in Sipser’s book, or during discussion sections, but clearly state the result you are using.

Do not turn this page until the instructor tells you to do so!

Problem 1

Problem 2

Problem 3

Problem 4

Total

Problem 1: [True or False, with justification] (30 points)

For each of the following questions, state TRUE or FALSE. Justify your answer in brief, indicating only the “proof idea” or counterexample, drawing a diagram if needed.

(a) If L is regular, then so is any subset of L.

(b) Consider the grammar G = ({S, A}, { 0 , 1 }, R, S) where R has the rules S → 0 S 1 | A 1 and A →  | 0 S Then L(G) contains the string 00111.

(c) The regular expression (10 ∪ 1)1∗^ generates the language {w | w ∈ { 0 , 1 }∗^ and w contains at least one 1 and at most one 0 }.

Problem 3: (20 points)

Let L = { 1 n^ | n is a prime number}. Prove L is not regular.

[Recall that an integer n is said to be composite (i.e., not prime) if there exists integers n 1 , n 2 > 1 such that n = n 1 n 2 .]

Problem 4: (25 points)

A two-stack pushdown automaton (2-stack PDA) is exactly like a pushdown automaton except that it has two stacks from which we can push and pop at each step. More formally, a 2-stack PDA consists of a 6-tuple (Q, Σ, Γ, δ, q 0 , F ) where the transition function is defined as δ : Q × Σ × Γ × Γ → 2 (Q×Γ×Γ)

If (q′, b′ 1 , b′ 2 ) ∈ (q, a, b 1 , b 2 ), it means that the 2-stack PDA can read the input character a, pop b 1 from the first stack, pop b 2 from the second stack, push b′ 1 onto the stack, push b′ 2 onto the stack, and go from state q to state q′. The acceptance condition for a 2-stack PDA is just as in the PDA.

(a) Let L 1 and L 2 be context-free languages. Show that L 1 ∩ L 2 is recognizable by a 2-stack automaton.