



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Exam; Class: Intro Theoretical Computer Sci; Subject: Computer Science and Engineering; University: Arizona State University - Tempe; Term: Fall 2006;
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!
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’ or
no’. Then give a justification to explain your answer. Yes. Recall the recursive definition of regular expressions:
, 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’ or
no’. 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 .