Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Successfully reported this slideshow.

Like this document? Why not share!

- To lec 03 by Hasam Panezai 2626 views
- Final Exam OS fall 2012-2013 with a... by Arab Open Univers... 31063 views
- Compilers Final spring 2013 model ... by Arab Open Univers... 833 views
- Infos2014 by Arab Open Univers... 471 views
- Model answer of compilers june spri... by Arab Open Univers... 465 views
- File Organization & processing Mid ... by Arab Open Univers... 755 views

1,052 views

Published on

No Downloads

Total views

1,052

On SlideShare

0

From Embeds

0

Number of Embeds

4

Shares

0

Downloads

36

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Full mark is out of 20Cairo University Midterm ExamFaculty of Computers & Information Spring 2013Dept. of Computer Science Time 1 hourCompilers DesignCS419Solve as much as you can. Full mark is out of twentyPart A: Regular expressions:1. ∑ ={a, b, c}; Formally describe all words for the language L that start with an afollowed by any number of b’s and then end with c. Give examples for words inthis language. [1 mark]Solution:L = a b*cGive 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 numberof 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 equivalentor not and explain your answer.(a*b*) and (ab)* [2mark]Solution:i. NOT equalThe language defined by the expression on the right contains the word abab, butthe language defined by the expression on the left does not.
- 2. Full mark is out of 20bbba,bbaSSS3+baSSS2+Sba,b-+SPart B: Finite Automata:∑ ={a, b}.6. Build two FAs (with different number of states) that accept only the word "ab".[1mark]Solution:RE = ab7. 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.[2mark]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 examplePosition 1 2 3 4 5Example1 a a a a bExample2 b a b a a[2 mark]Solution:a,ba,b-
- 3. Full mark is out of 20Aa1 2 3 4Part 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,baΛ ΛΛ

No public clipboards found for this slide

Be the first to comment