# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

7 Pages

### hw8-sols

Course: CS 273, Spring 2008
School: University of Illinois,...
Rating:

Word Count: 1257

#### Document Preview

273: CS Intro to Theory of Computation, Spring 2008 Problem Set 8 Solutions 1. Extract language from PDA. Give the language of the following PDA. b, , , b, , c, a ,\$ b, a ,\$ a, aa , \$ b, Solution: L = an bm |m| 2|n| an bm ck |k| = 2n, m &gt; 0 . 2. Converting CFG to PDA. For each of the following languages (with alphabet = {a, b}) construct a pushdown automaton recognizing that language,...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Illinois >> University of Illinois, Urbana Champaign >> CS 273

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
273: CS Intro to Theory of Computation, Spring 2008 Problem Set 8 Solutions 1. Extract language from PDA. Give the language of the following PDA. b, , , b, , c, a ,\$ b, a ,\$ a, aa , \$ b, Solution: L = an bm |m| 2|n| an bm ck |k| = 2n, m > 0 . 2. Converting CFG to PDA. For each of the following languages (with alphabet = {a, b}) construct a pushdown automaton recognizing that language, following the general construction for converting a context-free grammar to a PDA (lecture 13, pp. 115118 in Sipser). For each language, also give a parse tree for the word w, a leftmost derivation for w, and the first 10 configurations (state and stack contents) for the PDA as it accepts w. a) The word w = aababbaabbbb and the grammar with start symbol S: S aTTb T | Tab | aTb | b Solution: | b, A , \$S , bTTa C , baTb , bTa 1 ,\$ K Leftmost derivation for the string w: S aTTb aaTbTb aaTabbTb aababbTb aababbaTbb aababbaaTbbb aababbaabbbb. S a T T b a T b a T b T T b a b a b b format: state, stack (left to right, bottom to top), input consumed A, , = C, \$S, = C, \$bT T a, = C, \$bT T, a = C, \$bT bT a, a = C, \$bT bT, aa = C, \$bT bbaT, aa = C, \$bT bbab, aa = C, \$bT bba, aab = C, \$bT bb, aaba = b) The word w = babaabaabaaba and the grammar with start symbol S: S AB | B A BB | B B CC | b C aba Solution: , , S AB A S\$ B H ,\$ B , A BB ,S ,A B ,B ,B b b, CC , C aba a, a b 2 Leftmost derivation for the string w S AB BBB bCCB babaCB babaabaB babaabaCC babaabaabaC babaabaabaaba. S A B C a b a C a b a B b B C a b a C a b a format: state, stack (left to right, bottom to top), input consumed A, , = B, \$S, = B, \$BA, = B, \$BBB, = B, \$BBb, B, \$BB, b = B, \$BCC, b = B, \$BCaba, b = B, \$BCab, ba B, \$BCa, bab = 3. Language to PDA. Let = {a, b, c} and consider the language L = ai bj ck i = j or j = k for i, j, k 0 . = = Design a PDA for L. Present your PDA as a state diagram, with brief comments about how it works. We'll design the solution in four pieces, then assemble them into one PDA at the end. PDA accepting more as than bs in words of the form a b c : a, a a, \$ b, a c, Solution: A1 B a, , C ,\$ \$ D 3 PDA accepting more bs than as in words of the form a b c : a, a , \$ , b, a b, \$ \$ b, ,\$ \$ c, A2 B C D E PDA accepting (strictly) more cs than bs in words of the form a b c : a, , \$ , b, b , c, b c, \$ \$ c, A3 B C D E PDA accepting (strictly) more bs than cs in words of the form a b c : a, , \$ , b, b b, c, b ,\$ \$ A4 B C D E b, To assemble these pieces into the required automata, we add an initial state that goes, with an -transition ( , ) to A1 , A2 , A3 and A4 . This automata recognizes the required language, since the union of the languages of these four automatas is the required language. 4. Context-free grammar design. Let = {a, b}. A pair of strings (x, w) is an S-pair if they are identical except that two characters have been swapped. Formally, if x = c1 c2 . . . cn and w = d1 d2 . . . dn , then there are two character positions i and j such that ci = dj and cj = di , and ck = dk for k other than or i j. 4 (a) Notice that for any word x , it holds that (x, x) is always a S-pair. Briefly explain why. Solution: Take i = j then (x, x) is a trivial S-pair. (b) Let LS = wxR x, w and (x, w) is an S-pair . Give a context-free grammar that generates LS . Solution: S aSa | bSb | aAb | bBa | T A aAa | bAb | bTa B aBa | bBb | aTb T aTa | bTb | C C (c) Let LT = w1 #w2 # . . . wi # wi for all i and R i, j such that i < j and (wi , wj ) is an S-pair . Give a context-free grammar that generates LT . Solution: The grammar contains all the rules from part (b), except for the one for C, plus the following rules. Its start symbol is X. C W# W #V W | Z V# Z | VVV|a|b| X ZSW. To explain why this grammar works, here are the languages generated by the individual symbols. L(S) = L(Z) = ( #) L(W) = (# ) L(S) = w(# ) #x Here x and w are S-pair. L(X) = ( #) L(S)(# ) 5 5. Context-free grammar. (Bonus) The following grammar (with start symbol S) is ambiguous: S aS | aSbS | (a) Show that the grammar is ambiguous, by giving two parse trees for some string w. Solution: There are two ways to get the string aab: S a a S S b S S a a S S b S (b) Give an efficient test to determine whether a string w in L(S) is ambiguous. Explain informally why your test works. Solution: Claim 0.1 A word w L(S) is ambiguous, if you remove all the a's in the suffix of w, what remains is a word with strictly more a's than b's (and w contains at least one b). Proof: Consider the word w, and let x be the word remaining after we remove all the a's in its end. If x has only a single b, then its of the form aaa b, which is ambiguous, establishing the claim (furthermore, the two trees generating x can be easily extended to generate w). As such x has at least two b's in it. 6 Let T be the parse tree for x. This tree has three types of internal nodes: (i) S (ii) S aS (iii) S aSbS. If there is an inte...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Illinois, Urbana Champaign - CS - 273
CS 273: Intro to Theory of Computation, Spring 2008 Problem Set 14 Solutions1. Dovetailing (a) Briey sketch an algorithm for enumerating all Turing machine encodings. Remember that each encoding is just a string, with some specic internal syntax (e.
University of Illinois, Urbana Champaign - CS - 273
CS 273: Intro to Theory of Computation, Spring 2008 Problem Set 5 (due Monday, February 18th, 4pm)This homework contains only one problem, intended to help you study for the rst midterm. As usual, please turn in your homework at Elaine Wilsons oce (
University of Illinois, Urbana Champaign - CS - 579
PCPLecture 26 And Hardness of ApproximationThursday, April 24, 20081Promise ProblemsDecision problems, but with dont cares Specied by a Yes set and a No set, disjoint A TM is said to decide a promise problem if it correctly answers Yes or No
University of Illinois, Urbana Champaign - CS - 273
CS 273 Lecture 26: Posts Correspondence Problem and Tilings24 April 2008This lecture covers Posts Correspondence Problem (section 5.2 in Sipser). Undecidability of this problem implies the undecidability of CFG ambiguity. We will also see how to si
University of Illinois, Urbana Champaign - CS - 598
CS 598CSC: Approximation Algorithms Instructor: Chandra ChekuriLecture date: January 23, 2009 Scribe: Sungjin ImIn the previous lecture, we had a quick overview of several basic aspects of approximation algorithms. We also addressed approximation
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of Computation Sariel Har-Peled and Madhusudan ParthasarathyProblem Set 0Due: Thursday Jan 29 at 12:30 in class (i.e., SC 1105) This homework contains four problems (and one extra credit problem). Please follow the homework forma
University of Illinois, Urbana Champaign - CS - 373
CS 273 Lecture 26: Posts Correspondence Problem and Tilings24 April 2008This lecture covers Posts Correspondence Problem (section 5.2 in Sipser). Undecidability of this problem implies the undecidability of CFG ambiguity. We will also see how to si
University of Illinois, Urbana Champaign - CS - 373
CS 273, Lecture 22 Reductions10 April 2008This lecture covers basic undecidability reductions. This is the rst half of Sipser section 5.1 (through most of p. 192).1What is a reduction?Last lecture we proved that ATM is undecidable. Now that w
University of Illinois, Urbana Champaign - CS - 373
CS 273 Lecture : Review of topics coveredThis review of the class notes was written by Madhusudan Parthasarathy.1IntroductionThe theory of computation is perhaps the fundamental theory of computer science. It sets out to dene, mathematically,
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of Computation Sariel Har-Peled and Madhusudan ParthasarathyDiscussion 2: Examples of DFAs27 January 2009Purpose: This discussion demonstrates a few constructions of DFAs. How-ever, its main purpose is to show how to move fr
University of Illinois, Urbana Champaign - CS - 373
CS 273, Lecture 24 Linear Bounded Automata17 April 2008This lecture covers Linear Bounded Automata, an interesting compromise in power between Turing machines and the simpler automata (DFAs, NFAs, PDAs). We will use LBAs to show two CFG grammar pro
University of Illinois, Urbana Champaign - CS - 579
Complexity Homework 1Released: January 27, 2008 Due: February 10, 2008 For problems that involve nondeterministic complexity classes, the solutions maybe simpler when phrased in terms of certicates (instead of non-determinism). Problem 1: (a) Let L1
University of Illinois, Urbana Champaign - CS - 477
Homework Problem Set 1CS 477 Spring 2009Assigned: February 3, 2009 Due: February 10, 2009Instructions: You are welcome to collaborate while working out the ideas for a solution. However, you must write down the solutions independently, and must
University of Illinois, Urbana Champaign - CS - 579
Computational ComplexityLecture 1 in which we talk about Time Complexity, P, NP and coNPEvolution of ComputationEvolution of ComputationThe program (Turing Machine) starts in an initial conguration (tape-contents, control-state, headposition)
University of Illinois, Urbana Champaign - CS - 418
Some Sample Triangle MeshesWhat Polygon Meshes AreExplicit mesh description a list of polygonal faces F = ( f1, f2, , fn ) each polygon fi is a list of points this is sometimes called a polygon soup model vertices will be duplicated several ti
University of Illinois, Urbana Champaign - CS - 438
CS/ECE 438: Communication Networks Machine Problem 2Spring 2009 Due: 11:59 PM, Friday, March 20thReliable File TransferPlease read all sections of this document before you begin to code. Also, note that this is a challenging MP. It is not possib
University of Illinois, Urbana Champaign - CS - 438
CS/ECE 438: Communication Networks for Computers Problem Set 1Network Overview, Utilities and Basic ProbabilityAll problems carry equal weight. To receive full credit, show all of your work. 1.Spring 2009 SolutionsYou need 4TB / 8 GB = 500 flas
University of Illinois, Urbana Champaign - CS - 438
CS/ECE 438: Communication Networks Problem Set 3Fall 2007 Due Wednesday, Oct 17NOTE: There will be no automatic extension for this assignment. If you do not hand in the assignment by the start of class on Oct 17, you will get no credit for the as
University of Illinois, Urbana Champaign - CS - 438
CS/ECE 438: Communication Networks Problem Set 51. Slow StartFall 2007 Due Wednesday, Dec 5Assume a connection with RTT=50ms, MSS=1000 bytes. Ignoring overhead spent on headers, calculate the transfer time and the eective throughput for transfer
University of Illinois, Urbana Champaign - CS - 411
CS411 Database SystemsFall 2007HW#1Due: 3:00pm CST, 09/26/07Note: Print your name and NetID in the upper right corner of every page of your submission. Handin your stapled homework to Donna Coleman in 2120 SC. In case Donna is not in oce, slide
University of Illinois, Urbana Champaign - CS - 425
CS 425 Distributed Systems, Fall 2007, University of Illinois at Urbana-ChampaignMachine Problem 0 - TutorialDue Date - NoneOverviewThe machine programming (MP) part of the course this semester involves building a peer to peer application. We w
University of Illinois, Urbana Champaign - CS - 473
CS 473U: Algorithms, Fall 2007 Review and Practice Problems for Finals1. Recurrences and growth of functions. Review the problems in the homeworks and in midterm 1 and see if you can solve them now (without looking at the solutions!). 2. Problems 4.
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of ComputationAssigned: October 16, 2008 Due on: October 23, 2008Problem Set 6Instructions: This homework has two parts. The rst part has practice problems from the textbook many of whose solutions can be found in the textbook its
University of Illinois, Urbana Champaign - CS - 373
Problem Set 2CS 373: Theory of ComputationAssigned: September 11, 2008 Due on: September 18, 2008Instructions: This homework has two parts. The rst part has practice problems from the textbook many of whose solutions can be found in the textbook
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of ComputationAssigned: October 23, 2008 Due on: October 30, 2008Problem Set 6Instructions: This homework has two parts. The rst part has practice problems from the textbook many of whose solutions can be found in the textbook its
University of Illinois, Urbana Champaign - CS - 373
Problem Set 7CS 373: Theory of ComputationAssigned: October 23, 2008 Due on: October 30, 2008Instructions: This homework has two parts. The rst part has practice problems from the textbook many of whose solutions can be found in the textbook itse
University of Illinois, Urbana Champaign - CS - 440
Searching as Problem SolvingExample of Analytic Models(slightly more standard than textbook) N.B.: Lectures supercede textbook! World State Operators Preconditions Effects Goal Initial Stateattributes mechanism of change of operators of o
University of Illinois, Urbana Champaign - CS - 440
Issues The role of search What if we guess wrong about resolvents? Are there heuristics? Input / Unit Resolution Horn Clauses - PROLOG Completeness and refutational inferenceFrom Unsatisfiability to Returning AnswersSuppose that instead of
University of Illinois, Urbana Champaign - CS - 440
Admissibility of A*Some authors use A if not met 1) n n nodes, o operators with o(n)n h(n) cost(n,o,n) + h(n) Montonicity or Consistency (triangle inequality)Admissibility of A* (cont)2) n nodes h(n) h*(n) Informally: be optimistic (Why? Cou
University of Illinois, Urbana Champaign - CS - 440
CS 440: Introduction to AIHomework 2 Due: Tuesday, September 30th, 2008Your answers must be concise and clear. Explain suciently that we can easily determine what you understand. We will give more points for a brief interesting discussion with no a
University of Illinois, Urbana Champaign - CS - 440
The Infamous Dr. Bayes(or is logical inference really so bad?) Dr. Bayes has a statistics degree (not an MD) He makes diagnoses using his rule and other notions from statistics A plague has descended; there are two treatments: A and B He has tr
University of Illinois, Urbana Champaign - CS - 440
CS440: Introduction to AIHomework 4 Due: Thursday, November 13th, 2008Your answers must be concise and clear. Explain suciently that we can easily determine what you understand. We will give more points for a brief interesting discussion with no an
University of Illinois, Urbana Champaign - CS - 440
Midterm Exam October 7, in class A week from today! Search, Logic, Planning Unofficial sample midterms on web site Start reading Markov decision process &amp; reinforcement learning Chapters 17 &amp; 21Situation CalculusFOPC with some additional
University of Illinois, Urbana Champaign - CS - 440
Next: Appling Hybrid Models Beyond Planning Read Chapters 13 and 14 Uncertainty, Statistics, Probabilistic Reasoning Todays office hours 2-3 (not 3:30)Value Iterationsometimes TD for Temporal DifferencingUpdate:U ( s ) U ( s ) + rs +
University of Illinois, Urbana Champaign - CS - 440
Notation W, C, D, A, B are random variables C (binary presence of cavity) ranges over values Cs values might be Yes or No; 1 or 0; c1 or c2 Probability distribution: P(C) Probability value: P(C=c1) or P(c1) or P(c) P(A,B,C,W,D) full joint prob
University of Illinois, Urbana Champaign - CS - 440
CS 440: Introduction to AIHomework 1 Due: Tuesday September 9thYour answers must be concise and clear. Explain suciently that we can easily determine what you understand. We will give more points for a brief interesting discussion with no answer th
University of Illinois, Urbana Champaign - CS - 440
CS440 is my favorite classThere is some amount that I like CS440 and I like all other classes lessz w [Class(w) Name(w,CS440) Likes(Me,w,z) x y {[Class(x) Likes(Me,x,y) Different(x,w)] Greater(z,y)}] Likes(a,b,c) means a likes b by amount c G
University of Illinois, Urbana Champaign - CS - 440
Relevant TalkCoordinated Management of Multiple Interacting Resources on Chip Multiprocessors Jos Martnez, Cornell University November 17 (Monday), 4:00 p.m., 1404 Siebel Ph.D. Here w/ Torrellas, seen the light &amp; now uses machine learning: Artificia
University of Illinois, Urbana Champaign - CS - 440
Announcements Homework 2: logic, representation, inference Became available over the weekend Due Sept. 30 (one week from today) Its a bit long dont wait! You are reading Chapters 11 &amp; 12 (planning &amp; action) I know of a few projects (but not m
University of Illinois, Urbana Champaign - CS - 440
Announcements Final 7-8:15 PM, 12/16 here Projects (for 4th unit) due today Thursday 12:30, Q/A session 1105 SC (not here) Previous final exams on web siteAgnostic Learning Same thing but no guarantee h*H Possibly, no h is consistent over S
University of Illinois, Urbana Champaign - CS - 440
CS 440: Introduction to AIHomework 1 Due: Tuesday September 9thYour answers must be concise and clear. Explain suciently that we can easily determine what you understand. We will give more points for a brief interesting discussion with no answer th
University of Illinois, Urbana Champaign - CS - 440
CS440: Introduction to AIHomework 4 Due: Thursday, November 13th, 2008Your answers must be concise and clear. Explain suciently that we can easily determine what you understand. We will give more points for a brief interesting discussion with no an
University of Illinois, Urbana Champaign - CS - 440
Machine Problem 1* Group work (4-5 members) Start immediately; hard (but easy programming) Email ta440@cs.uiuc.edu for Help forming groups An EWS account (no Eng major in group) 2 Parts, due 10/28 and 11/4 (election day!)* FINE PRINT: Althoug
University of Illinois, Urbana Champaign - CS - 440
Search Useful by themselves they re-emerge often in AI Mostly (for us) a first illustration of World Model Pedagogical Intractable for Hard problems (Hard = ?) Two paradigms (can be combined) Satisfiability OptimizationCould we add an empir
University of Illinois, Urbana Champaign - CS - 440
Announcements Projects (for 4th unit) due class time Tuesday Code Sample runs Paper (what you did, what you learned) Possibility of extension to Friday (ask) HW5 available, practice only Final 7-8:15 PM, 12/16 hereWhy No? Thres
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of ComputationAssigned: September 18, 2008 Due on: September 25, 2008Problem Set 3Instructions: This homework has two parts. The rst part has practice problems from the textbook many of whose solutions can be found in the textbook
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of ComputationAssigned: November 13, 2008 Problem 1. 3.9 Solution A k-PDA is a pushdown automata with k independent stacks. Each transition in state will push and pop a character from each of the stacks, but otherwise behaves like and
University of Illinois, Urbana Champaign - CS - 241
This lecture Classical Synchronization ProblemsIndranil Gupta (Indy) Goals:Introduce classical synchronization problemsTopicsProducer-Consumer Problem Reader-Writer Problem Dining Philosophers Problem Sleeping Barbers ProblemCopyright : Nahrst
University of Illinois, Urbana Champaign - CS - 373
Midterm 1CS 373: Theory of ComputationDate: Thursday, October 2, 2008. Instructions: This is a closed book exam. No notes, cheat sheets, textbook, or printed material allowed. You have 120 minutes to solve this exam. There are 6 problems in this
University of Illinois, Urbana Champaign - CS - 373
CS 373: Theory of ComputationManoj Prabhakaran Mahesh Viswanathan Fall 2008111.1UndecidabilityRecapDecision Problems and Languages A decision problem requires checking if an input (string) has some property. Thus, a decision problem is a
University of Illinois, Urbana Champaign - CS - 425
Homework 3 (Election, Consensus Problem, Failure Detectors, P2P) - 100 Points SolutionsCS425 Distributed Systems, Fall 2008, Instructor: Klara Nahrstedt 1. (30 Points) Let us assume 8 processes, P1, P2, P3, P4, P5, P6, P7, P8. Let us assume that pro
University of Illinois, Urbana Champaign - CS - 373
CS 273, Fall 2008 Exam 1 SolutionsProblem 1: Short Answer (8 points)The answers to these problems should be short and not complicated. (a) If an NFA M accepts the empty string (i.e., ), does M s start state have to be an accepting state? Why or why
University of Illinois, Urbana Champaign - CS - 498
CS 498 JH: Introduction to NLP (Fall 08)Lecture 12: Discriminative Parsing ModelsThe problem with generative modelsJulia Hockenmaierjuliahmr@illinois.edu 3324 Siebel Center Ofce Hours: Tue, 2:00-3:30pm http:/www.cs.uiuc.edu/class/fa08/cs498jh
University of Illinois, Urbana Champaign - ECE - 428
CS 425 / ECE 428 / CSE 424: Distributed Systems Homework 1 - Due on February 10th , 2009Spring 2009The following problems are assigned from the 4th edition of CDK. 3rd edition users please check with your classmates for corresponding problem numb
University of Illinois, Urbana Champaign - ECE - 428
CS 425 / ECE 428 / CSE 424: Distributed Systems Homework 2 - Due on February 24th , 2009Spring 2009You are encouraged to exchange ideas taught in the course; however, should you discuss any homework problems with others, you should independently
University of Illinois, Urbana Champaign - ECE - 534
ECE 534 RANDOM PROCESSES PROBLEM SET 6FALL 2008 Due Wednesday, November 196. Basic Calculus of Random Processes Assigned Reading: Chapter 7 and Sections 11.3-11.5 of the notes. Reminder: Exam 2, covering lectures, reading, and homework for proble
University of Illinois, Urbana Champaign - ECE - 534
ECE 534 RANDOM PROCESSES PROBLEM SET 2FALL 2008 Due Friday, September 262. Convergence of a Sequence of Random Variables Assigned Reading: Chapter 2 and Sections 11.1-11.2 of the course notes. Additional material on limits for deterministic seque
University of Illinois, Urbana Champaign - ECE - 534
ECE 434 RANDOM PROCESSES PROBLEM SET 2SPRING 2003 Due Wednesday, February 19Sequences of Random Variables Assigned Reading: Chapter 2 and Sections 8.1-8.3 of the course notes. Additional material on limits for deterministic sequences can be found
University of Illinois, Urbana Champaign - ECE - 534
ECE 534 RANDOM PROCESSES PROBLEM SET 6SPRING 2005 Due Wednesday, November 16Random Processes in Linear Systems and Spectral Analysis Assigned Reading: Chapter 6 of the course notes. Reminder: Exam 2 will be given Monday, November 7, 7-8:15 p.m. i
University of Illinois, Urbana Champaign - ECE - 534
ECE 534 RANDOM PROCESSES PROBLEM SET 2 Sequences of Random VariablesFALL 2005 Due September 21Assigned Reading: Chapter 2 and Sections 8.1-8.3 of the course notes. Additional material on limits for deterministic sequences can be found in Kenneth
University of Illinois, Urbana Champaign - ECE - 534
ECE 434 RANDOM PROCESSES PROBLEM SET 3SPRING 2003 Due Wednesday, March 5Random Vectors and Minimum Mean Squared Error Estimation Assigned Reading: Chapter 3 and the section on matrices in the Appendix, in the course notes. Problems to be handed i