20 views

Original Title: hw4

Uploaded by Umer Khan

- CS402 Subjective
- compiler notes
- Automata and Compiler Design Jntu Model com
- Data Structures in c
- Learning to Program With Haiku Lesson 5
- Docu
- 3
- YARA User's Manual 12323
- Lr Functions
- String Functions
- 080 Semantic Analysis
- Theory of Computation.pdf
- Regular Expression
- Excel Programming Basic
- How to Store File Incoming as XSTRING in SAP
- nlp6v2
- 6 Collections
- mc_sim_commands
- Practical 1
- v062-e1-03

You are on page 1of 2

1. Context-free grammars. Give CFGs generating each of the following languages. In all cases, i, j, k 0. (a) {x {a, b} | x starts and ends with the same symbol} (b) {ai bj ck | i = j or j = k } (c) {ai bj ck | i = j + k } (d) {ai bj ck | i = j + k } (e) {ai bj ck | i < j or i > k } 2. Applications of CFGs. Find a CFG generating the language of all regular expressions over the alphabet = {0, 1} (including the R+ operation is not necessary): (a) if the denition of regular expression is interpreted strictly with regard to parentheses (fully parenthesized), for example, ((((01) ) 0)(0 )) (as specied on page 64 of the textbook); (b) if the denition is interpreted so as to allow regular expressions that are not fully parenthesized, for example, (01 111) 0. In this case, any grammar is sucient even if it is ambiguous and doesnt properly enforce the precedence order of the operations. Be careful to distinguish between -substitution rules and substitution rules whose right side is the symbol appearing in a regular expression; use E in the second case. 3. Normal forms. Convert the following grammars to Chomsky normal form: (a) S AB | (b) S aSa | B B bbC | bb C cC | 4. Properties of CFGs. (a) A variable A in a CFG G = (V, , R, S ) is reachable if a string that contains it can be derived from the start variable S . In other words, S uAw, where denotes multiple derivation steps and u, w are strings consisting of variables and terminals (i.e., u, w (V ) ). Give an algorithm for nding all reachable variables in G. (Hint: the algorithm is similar to computing reachable states in a DFA.) (b) A variable A in a CFG G = (V, , R, S ) is live if a string consisting of terminals only can be derived from it. In other words, A x for some x . Give an algorithm for nding all live variables in G. (c) Extra credit. A variable A in a CFG G = (V, , R, S ) is useful if for some string x , there is a derivation of x that takes the form S uAw x (i.e., it is both reachable and live). A variable that is not useful is useless. If a grammar has useless variables, it is possible to construct an equivalent grammar with no useless variables. A aASb | a B bS

Give an algorithm for doing so and nd equivalent CFGs with no useless variables for the grammars below: S ABC | BaB A aA | BaC | aaa A aAb | bAa | a B bBb | a C CA | AC

S AB | AC

B bbA | aaB | AB

C abCa | aDb

D bD | aC

- CS402 SubjectiveUploaded byzaaiby
- compiler notesUploaded byNima Seyedtalebi
- Automata and Compiler Design Jntu Model comUploaded bysapabaplive
- Data Structures in cUploaded byRaghavendiran J M
- Learning to Program With Haiku Lesson 5Uploaded byboromil
- DocuUploaded byManoj Prasad
- 3Uploaded byAnonymous wIAJp9QbFX
- YARA User's Manual 12323Uploaded byc121
- Lr FunctionsUploaded byfella10
- String FunctionsUploaded byAbhilash Gupta
- 080 Semantic AnalysisUploaded byDiego Rojas
- Theory of Computation.pdfUploaded byPRINCE DEWANGAN
- Regular ExpressionUploaded bysuhas_kognole1575
- Excel Programming BasicUploaded bymahmoud.alnouri2099
- How to Store File Incoming as XSTRING in SAPUploaded byjagadeeswar
- nlp6v2Uploaded byahmed hmed
- 6 CollectionsUploaded bymubashirKhazir
- mc_sim_commandsUploaded byJose Cora
- Practical 1Uploaded byvarun
- v062-e1-03Uploaded byAmy Adams
- Reg Expressions in RUploaded bynalluri_08
- Cadenas de Caracteres en PHPUploaded byperexwi
- Grads PresentationUploaded bymuhammad arif setyo aji
- A Real-World Need for C Extension in the RubyUploaded bybacancytech
- speakmath.pdfUploaded byFulki Kautsar S
- pynotas.pdfUploaded byPablo Alvarez Corredera
- AX 2012 Validating Numbers Using Regular ExpressionsUploaded byJ Eduardo T Ontaneda
- d Scouse PlanUploaded bynooti
- Parameter UAT RAC LinuxUploaded byChuong Nguyen
- MCA_ITA419_cyclesheet_2Uploaded byakshayt044

- AIM for Oracle ImplementationUploaded byManish Chaturvedi
- Capio OverviewUploaded byAkhilesh Asare
- Large Quantity of Inventory Items With Null List Price Cannot Be Updated [ID 729641.1]Uploaded bygrameenp
- Robotics Systems ReportUploaded bykentesh
- nwUploaded byRamesh Bandari
- Www Go4expert Com Articles Multiple Choice Questions Perl t21042Uploaded byDeepak Thapa
- LgSoft Sample PROGRAMMING Placement PaperUploaded byPuli Naveen
- BPMN 2 0-TutorialUploaded bytony_aessd9130
- Imp QuestionsUploaded byRishabh Jain
- ViewsUploaded byBitu Patnaik
- introd.pptUploaded bykaylaroberts
- Cocoa FundamentalsUploaded bymarrgm
- AssignmentUploaded byShubham
- 94961251-Semester-2-Mid-Term-Exam-2.pdfUploaded byAziz Fikri
- Djangogirls2_URLConfUploaded byKaleab Tekle
- 256984main Web Application MethodologyUploaded byAsha Sumitha
- User ManualUploaded bymeenafacebook
- 10th Class Computer Science Notes by Sir TahirUploaded byTahir Mehmood
- sys600Uploaded bysahilcc
- PythonUploaded byronnny11
- 1st ARRAY.pptxUploaded byFirman Prayoga
- Style Build 02Uploaded byPutina Adrian
- Introduction to ASP.net Web API - CodeProjectUploaded byvenki4b2
- 1993 - Karner - Resource Estimation for Objectory ProjectsUploaded byNurjamin
- Structured Query LanguageUploaded byParul Batra
- COBOL Tutorial SiMpleUploaded byRamana Varala
- Git PrimerUploaded byKeith Xavier Mascarenhas
- CollectionUploaded byjralbendin
- ASP SkriptaUploaded byNermin Boja
- Pcd RecordUploaded byblacklistrivals711