Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Midterm Exam with Questions - Introduction Theoretical Computer Science | CSE 355, Exams of Computer Science

Material Type: Exam; Class: Intro Theoretical Computer Sci; Subject: Computer Science and Engineering; University: Arizona State University - Tempe; Term: Fall 2006;

Typology: Exams

Pre 2010

Uploaded on 09/02/2009

koofers-user-f02
koofers-user-f02 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 355 Theory of Computing ID: 123-45-6789
Fall 2006 - Colbourn Bonus Midterm Page 1 of 7
14 November 2006
NAME
Ima Student
ASU ID
123-45-6789
You have one hour and 15 minutes to complete the exam.
Do not open the exam until you are instructed to do so.
No notes, texts, computers, calculators, or communication devices are
permitted. Write all answers on the examination paper itself.
BUDGET YOUR TIME WELL!
SHOW ALL WORK!
New
Midterm 1
Grade (out of 60)
New
Midterm 2
Grade (out of 60)
Bonus: Canada has 10 provinces and three territories.
Question 1
[20]
Question 2
[20]
Question 3
[10]
Question 4
[10]
Total
[60]
pf3
pf4
pf5

Partial preview of the text

Download Midterm Exam with Questions - Introduction Theoretical Computer Science | CSE 355 and more Exams Computer Science in PDF only on Docsity!

Fall 2006 - Colbourn Bonus Midterm Page 1 of 7 14 November 2006 NAME Ima Student ASU ID 123 - 45 - 6789 You have one hour and 15 minutes to complete the exam. Do not open the exam until you are instructed to do so. No notes, texts, computers, calculators, or communication devices are permitted. Write all answers on the examination paper itself. BUDGET YOUR TIME WELL! SHOW ALL WORK! New Midterm 1 Grade (out of 60) New Midterm 2 Grade (out of 60) Bonus: Canada has 10 provinces and three territories. Question 1 [20] Question 2 [20] Question 3 [10] Question 4 [10] Total [60]

Fall 2006 - Colbourn Bonus Midterm Page 2 of 7 [20 total] Question 1: Consider the language L = {a i b j c k : i > j and k=i-j}. [6] 1a) Show that L is not regular. Suppose to the contrary that L is regular, and let k be the constant specified by the pumping lemma. Look at a k b 0 c k- 0

. By the pumping lemma the string can be written as uvw. Because length(uv) < k, v must only contain a’s. Pump v 0 times: uv 0 w is a k-length(v) b 0 c k . Since length(v) > 0, k- length(v) ≠ k, and uv 0 w is not in L; therefore L is not regular. [6] 1b) Show that L is context-free by giving a PDA for L. Note that after all a’s and b’s are processed, there must still be an A on the stack – this ensures that i > j. [8] 1c) Give a context-free grammar for L in Chomsky normal form. S → aSc | aFc F → aFb | λ S → aNc | aFc | ac N → aNc | F | ac F → aFb | ab S → AM | AC M → NC N → AM | AG | AC F → AG | AB G → FB A → a B → b C → c

Fall 2006 - Colbourn Bonus Midterm Page 4 of 7 [5] 2c) Give an NFA for L. See either 2b or 2d. Both are ok. [5] 2d) Give a DFA for L. State New State a New State b Start/Accept? {q0} {q1} ∅^ Start {q1} ∅^ {q2} {q2} {q3,q5} ∅^ Accept {q3,q5} ∅^ {q4,q6} {q4,q6} {q3,q7} ∅^ Accept {q3,q7} {q5} {q4} Accept {q4} {q3} ∅^ Accept {q3} ∅^ {q4} {q5} ∅^ {q6} {q6} {q7} ∅ {q7} {q5} ∅^ Accept ∅ ∅ ∅

Fall 2006 - Colbourn Bonus Midterm Page 5 of 7 [10] Question 3. Let L be a language and let L rev denote the language {w rev : w ∈ L}. [5] 3a) Is L rev regular whenever L is regular? Answer yes’ orno’. Then give a justification to explain your answer. Yes. Recall the recursive definition of regular expressions:

  1. λ is an r.e. and any a in Σ (the finite alphabet) is an r.e.
  2. If L and M are r.e.’s then so are (L U M), (LM), and L
    • .
  3. Every r.e. is the result of a fine number of applications of rule (2). This gives an inductive proof as follows: BASIS: λ = λ rev and a = a rev when a in Σ INDUCTION HYPOTHESIS: If L is a r.e. produced in k or fewer applications of rule (2), then L rev is generated by an r.e. INDUCTION STEP: To prove: If L is a r.e. produced in k+1 applications of rule (2), then L rev is generated by an r.e. If L = MN, L = (M U N), or L = M

, then M and N are generated by r.e.’s using k or fewer steps and thus by the induction hypothesis, M rev and N rev are generated by r.e.’s. But (MN) rev = (N rev M rev ), (M U N) rev = (M rev U N rev ), and (M

) rev = ((M rev )

), and hence L rev is generated by an r.e. [5] 3b) Is L rev context-free whenever L is context-free? Answer yes’ orno’. Then give a justification to explain your answer. Yes. Since L is CF, there is a CFG in Chomsky normal form whose language is L. If we reverse the order of the right-hand sides of each rule in the grammar, we obtain another CFG (also in Chomsky normal form). The language of this new CFG is L rev .