SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
Full mark is out of 20
Cairo University Midterm Exam
Faculty of Computers & Information Spring 2013
Dept. of Computer Science Time 1 hour
Compilers DesignCS419
Solve as much as you can. Full mark is out of twenty
Part A: Regular expressions:
1. ∑ ={a, b, c}; Formally describe all words for the language L that start with an 'a'
followed by any number of 'b'’s and then end with 'c'. Give examples for words in
this language. [1 mark]
Solution:
L = a b*c
Give examples for words in L
{ac, abc,abc,abbc, abbbc …..}
2. ∑ ={a, b}; All words with even count of letters. [2 mark]
Solution:
((a+b)(a+b))*
examples for words in L
{ Λ, aa,bb,ab,ba,bb,aaaa,…..}
3. ∑ ={a, b}; Construct a regular expression for:
a. All strings that end in a double letter. [2 mark]
b. All strings that do not end in a double letter. [2 mark]
Solution:
a. (a + b)*(aa + bb)
b. ((a + b)*(ab + ba)) + a + b + Λ
Note: Provide for strings containing zero or one letter too by + Λ
4. ∑ ={a, b};Construct a regular expression for all strings in which the total number
of 'a'’s is divisible by 3 no matter how they are distributed, such as “aabaabbaba”.
[2 mark]
Solution:
(b*ab*ab*ab*)*
5. ∑ ={a, b}, State whether the following pair of regular expressions are equivalent
or not and explain your answer.(a*b*) and (ab)* [2
mark]
Solution:
i. NOT equal
The language defined by the expression on the right contains the word abab, but
the language defined by the expression on the left does not.
Full mark is out of 20
b
b
b
a,b
ba
S
S
S3
+
ba
S
S
S2
+
S
ba,b
-+
S
Part B: Finite Automata:
∑ ={a, b}.
6. Build two FAs (with different number of states) that accept only the word "ab".
[1
mark]
Solution:
RE = ab
7. Build FA with one state that accepts anything. [1 mark]
Solution:
RE = (a+b)*
8. Build FA that accepts only words that have an even number of letters.
[2
mark]
Solution:
9. All words with even count of letters where even positions must contain an “a”,
and the first letter is letter number one. (a+b)a((a+b)a)*.
For example
Position 1 2 3 4 5
Example1 a a a a b
Example2 b a b a a
[2 mark]
Solution:
a,b
a,b
-
Full mark is out of 20
A
a
1 2 3 4
Part C: NFA:
10. Construct an NFA (with ε transitions) for (ab)*(aab)* [3 mark]
Solution:
Part D: NFA to DFA:
11. For the given NFA, construct the equivalent DFA [3 mark]
Solution:
Closure of 1 ={1,2,4}
Closure of 2 = {2}
Closure of 3 = {2, 3,4}
Closure of 4 = {4}
-
a,
b
aΛ Λ
Λ

Más contenido relacionado

La actualidad más candente

Regular expressions
Regular expressionsRegular expressions
Regular expressionsShiraz316
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA constructionAkila Krishnamoorthy
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Abhimanyu Mishra
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryTsegazeab Asgedom
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplicationMegha V
 
Generalized transition graphs
Generalized transition graphsGeneralized transition graphs
Generalized transition graphsArham Khan G
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automatahafizhamza0322
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Srimatre K
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressionsSampath Kumar S
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 

La actualidad más candente (20)

Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA construction
 
Finite automata
Finite automataFinite automata
Finite automata
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3
 
Lesson 11
Lesson 11Lesson 11
Lesson 11
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
Generalized transition graphs
Generalized transition graphsGeneralized transition graphs
Generalized transition graphs
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
2 homework
2 homework2 homework
2 homework
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 

Destacado

Os solved question paper
Os solved question paperOs solved question paper
Os solved question paperAnkit Bhatnagar
 
Regular Expression
Regular ExpressionRegular Expression
Regular ExpressionBharat17485
 
Question, mark scheme, examiners report and model answer jan 13
Question, mark scheme, examiners report and model answer jan 13Question, mark scheme, examiners report and model answer jan 13
Question, mark scheme, examiners report and model answer jan 13mattbentley34
 
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEMFINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEMAmira Dolce Farhana
 
Unit 2: Excellent revision aid..a must for all students
Unit 2: Excellent revision aid..a must for all studentsUnit 2: Excellent revision aid..a must for all students
Unit 2: Excellent revision aid..a must for all studentsmattbentley34
 
Operating system notes
Operating system notesOperating system notes
Operating system notesSANTOSH RATH
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)Sohaib Danish
 
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...vtunotesbysree
 
Operating System Multiple Choice Questions
Operating System Multiple Choice QuestionsOperating System Multiple Choice Questions
Operating System Multiple Choice QuestionsShusil Baral
 
Collections of CS Multiple Choice Questions
Collections of CS Multiple Choice QuestionsCollections of CS Multiple Choice Questions
Collections of CS Multiple Choice QuestionsShusil Baral
 
Basic IT Multiple Choice Questions
Basic IT Multiple Choice QuestionsBasic IT Multiple Choice Questions
Basic IT Multiple Choice QuestionsShusil Baral
 
Computer Networking Multiple Choice Questions
Computer Networking Multiple Choice QuestionsComputer Networking Multiple Choice Questions
Computer Networking Multiple Choice QuestionsShusil Baral
 

Destacado (20)

To lec 03
To lec 03To lec 03
To lec 03
 
Final Exam OS fall 2012-2013 with answers
Final Exam OS fall 2012-2013 with answersFinal Exam OS fall 2012-2013 with answers
Final Exam OS fall 2012-2013 with answers
 
Infos2014
Infos2014Infos2014
Infos2014
 
Model answer of compilers june spring 2013
Model answer of compilers june spring 2013Model answer of compilers june spring 2013
Model answer of compilers june spring 2013
 
File Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswerFile Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswer
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
 
Os solved question paper
Os solved question paperOs solved question paper
Os solved question paper
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
CS215 - Lec 4 single record organization
CS215 - Lec 4  single record organizationCS215 - Lec 4  single record organization
CS215 - Lec 4 single record organization
 
Question, mark scheme, examiners report and model answer jan 13
Question, mark scheme, examiners report and model answer jan 13Question, mark scheme, examiners report and model answer jan 13
Question, mark scheme, examiners report and model answer jan 13
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEMFINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
 
Unit 2: Excellent revision aid..a must for all students
Unit 2: Excellent revision aid..a must for all studentsUnit 2: Excellent revision aid..a must for all students
Unit 2: Excellent revision aid..a must for all students
 
Operating system notes
Operating system notesOperating system notes
Operating system notes
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
 
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
 
Operating System Multiple Choice Questions
Operating System Multiple Choice QuestionsOperating System Multiple Choice Questions
Operating System Multiple Choice Questions
 
Collections of CS Multiple Choice Questions
Collections of CS Multiple Choice QuestionsCollections of CS Multiple Choice Questions
Collections of CS Multiple Choice Questions
 
Basic IT Multiple Choice Questions
Basic IT Multiple Choice QuestionsBasic IT Multiple Choice Questions
Basic IT Multiple Choice Questions
 
Computer Networking Multiple Choice Questions
Computer Networking Multiple Choice QuestionsComputer Networking Multiple Choice Questions
Computer Networking Multiple Choice Questions
 

Similar a Compilers midterm spring 2013 model answer

12 -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]
12  -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]12  -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]
12 -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]Rabi Iftikhar
 
regular expressions (Regex)
regular expressions (Regex)regular expressions (Regex)
regular expressions (Regex)Rebaz Najeeb
 
Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........NaumanAli215439
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Lesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptLesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptashja1
 
Theory of Automata Lesson 01
 Theory of Automata Lesson 01  Theory of Automata Lesson 01
Theory of Automata Lesson 01 hamzamughal39
 
Alphabets , strings, languages and grammars
Alphabets , strings, languages  and grammarsAlphabets , strings, languages  and grammars
Alphabets , strings, languages and grammarshele987
 
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptxGhulamRabani9
 
Handout Regular expression with examples and lecture
Handout Regular expression with examples  and lecture Handout Regular expression with examples  and lecture
Handout Regular expression with examples and lecture mariajan8
 
Expresiones Algebraicas
Expresiones AlgebraicasExpresiones Algebraicas
Expresiones AlgebraicasDargelisGomez1
 

Similar a Compilers midterm spring 2013 model answer (20)

Lesson 04
Lesson 04Lesson 04
Lesson 04
 
12 -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]
12  -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]12  -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]
12 -csc312_automat_theory_assign-1_(27-09-12)_(1)[1]
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
regular expressions (Regex)
regular expressions (Regex)regular expressions (Regex)
regular expressions (Regex)
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
 
Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
Language
LanguageLanguage
Language
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Lesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptLesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.ppt
 
Theory of Automata Lesson 01
 Theory of Automata Lesson 01  Theory of Automata Lesson 01
Theory of Automata Lesson 01
 
Lesson 09.ppt
Lesson 09.pptLesson 09.ppt
Lesson 09.ppt
 
Alphabets , strings, languages and grammars
Alphabets , strings, languages  and grammarsAlphabets , strings, languages  and grammars
Alphabets , strings, languages and grammars
 
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptx
 
Handout Regular expression with examples and lecture
Handout Regular expression with examples  and lecture Handout Regular expression with examples  and lecture
Handout Regular expression with examples and lecture
 
Linear Algebra Assignment Help
Linear Algebra Assignment HelpLinear Algebra Assignment Help
Linear Algebra Assignment Help
 
Expresiones Algebraicas
Expresiones AlgebraicasExpresiones Algebraicas
Expresiones Algebraicas
 
3rd Semester Computer Science and Engineering (ACU) Question papers
3rd Semester Computer Science and Engineering  (ACU) Question papers3rd Semester Computer Science and Engineering  (ACU) Question papers
3rd Semester Computer Science and Engineering (ACU) Question papers
 

Más de Arab Open University and Cairo University

Más de Arab Open University and Cairo University (20)

Theory of computation Lec6
Theory of computation Lec6Theory of computation Lec6
Theory of computation Lec6
 
Lec4
Lec4Lec4
Lec4
 
Theory of computation Lec1
Theory of computation Lec1Theory of computation Lec1
Theory of computation Lec1
 
Theory of computation Lec7 pda
Theory of computation Lec7 pdaTheory of computation Lec7 pda
Theory of computation Lec7 pda
 
Setup python with eclipse
Setup python with eclipseSetup python with eclipse
Setup python with eclipse
 
Cs419 lec8 top-down parsing
Cs419 lec8    top-down parsingCs419 lec8    top-down parsing
Cs419 lec8 top-down parsing
 
Cs419 lec11 bottom-up parsing
Cs419 lec11   bottom-up parsingCs419 lec11   bottom-up parsing
Cs419 lec11 bottom-up parsing
 
Cs419 lec12 semantic analyzer
Cs419 lec12  semantic analyzerCs419 lec12  semantic analyzer
Cs419 lec12 semantic analyzer
 
Cs419 lec9 constructing parsing table ll1
Cs419 lec9   constructing parsing table ll1Cs419 lec9   constructing parsing table ll1
Cs419 lec9 constructing parsing table ll1
 
Cs419 lec10 left recursion and left factoring
Cs419 lec10   left recursion and left factoringCs419 lec10   left recursion and left factoring
Cs419 lec10 left recursion and left factoring
 
Cs419 lec7 cfg
Cs419 lec7   cfgCs419 lec7   cfg
Cs419 lec7 cfg
 
Cs419 lec6 lexical analysis using nfa
Cs419 lec6   lexical analysis using nfaCs419 lec6   lexical analysis using nfa
Cs419 lec6 lexical analysis using nfa
 
Cs419 lec5 lexical analysis using dfa
Cs419 lec5   lexical analysis using dfaCs419 lec5   lexical analysis using dfa
Cs419 lec5 lexical analysis using dfa
 
Cs419 lec4 lexical analysis using re
Cs419 lec4   lexical analysis using reCs419 lec4   lexical analysis using re
Cs419 lec4 lexical analysis using re
 
Cs419 lec3 lexical analysis using re
Cs419 lec3   lexical analysis using reCs419 lec3   lexical analysis using re
Cs419 lec3 lexical analysis using re
 
Cs419 Compiler lec1&2 introduction
Cs419 Compiler lec1&2  introductionCs419 Compiler lec1&2  introduction
Cs419 Compiler lec1&2 introduction
 
CS215 - Lec 8 searching records
CS215 - Lec 8  searching recordsCS215 - Lec 8  searching records
CS215 - Lec 8 searching records
 
CS215 - Lec 7 managing records collection
CS215 - Lec 7  managing records collectionCS215 - Lec 7  managing records collection
CS215 - Lec 7 managing records collection
 
CS215 - Lec 6 record index
CS215 - Lec 6  record indexCS215 - Lec 6  record index
CS215 - Lec 6 record index
 
CS215 - Lec 5 record organization
CS215 - Lec 5  record organizationCS215 - Lec 5  record organization
CS215 - Lec 5 record organization
 

Último

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Último (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Compilers midterm spring 2013 model answer

  • 1. Full mark is out of 20 Cairo University Midterm Exam Faculty of Computers & Information Spring 2013 Dept. of Computer Science Time 1 hour Compilers DesignCS419 Solve as much as you can. Full mark is out of twenty Part A: Regular expressions: 1. ∑ ={a, b, c}; Formally describe all words for the language L that start with an 'a' followed by any number of 'b'’s and then end with 'c'. Give examples for words in this language. [1 mark] Solution: L = a b*c Give examples for words in L {ac, abc,abc,abbc, abbbc …..} 2. ∑ ={a, b}; All words with even count of letters. [2 mark] Solution: ((a+b)(a+b))* examples for words in L { Λ, aa,bb,ab,ba,bb,aaaa,…..} 3. ∑ ={a, b}; Construct a regular expression for: a. All strings that end in a double letter. [2 mark] b. All strings that do not end in a double letter. [2 mark] Solution: a. (a + b)*(aa + bb) b. ((a + b)*(ab + ba)) + a + b + Λ Note: Provide for strings containing zero or one letter too by + Λ 4. ∑ ={a, b};Construct a regular expression for all strings in which the total number of 'a'’s is divisible by 3 no matter how they are distributed, such as “aabaabbaba”. [2 mark] Solution: (b*ab*ab*ab*)* 5. ∑ ={a, b}, State whether the following pair of regular expressions are equivalent or not and explain your answer.(a*b*) and (ab)* [2 mark] Solution: i. NOT equal The language defined by the expression on the right contains the word abab, but the language defined by the expression on the left does not.
  • 2. Full mark is out of 20 b b b a,b ba S S S3 + ba S S S2 + S ba,b -+ S Part B: Finite Automata: ∑ ={a, b}. 6. Build two FAs (with different number of states) that accept only the word "ab". [1 mark] Solution: RE = ab 7. Build FA with one state that accepts anything. [1 mark] Solution: RE = (a+b)* 8. Build FA that accepts only words that have an even number of letters. [2 mark] Solution: 9. All words with even count of letters where even positions must contain an “a”, and the first letter is letter number one. (a+b)a((a+b)a)*. For example Position 1 2 3 4 5 Example1 a a a a b Example2 b a b a a [2 mark] Solution: a,b a,b -
  • 3. Full mark is out of 20 A a 1 2 3 4 Part C: NFA: 10. Construct an NFA (with ε transitions) for (ab)*(aab)* [3 mark] Solution: Part D: NFA to DFA: 11. For the given NFA, construct the equivalent DFA [3 mark] Solution: Closure of 1 ={1,2,4} Closure of 2 = {2} Closure of 3 = {2, 3,4} Closure of 4 = {4} - a, b aΛ Λ Λ