SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
Page 1 of 5
Cairo University
Faculty of Computers and Information
Postgraduate Final Exam (Pre-masters)
Department : Computer science
Lecturer : Dr. Hussien Sharaf
Course : Theory of computation
Course Code : CS611 Marks : 60 marks
Date : 1-June-2013 Time : 2 hours
Solve only five questions, given that questions one and two are
mandatory:
Question 1[mandatory] [15 marks]
For each of the following languages do the following:
i. Understand the languages without any assistance;
ii. Write sample words for the language where you show the smallest possible
word.
iii. Construct a regular expression that represents the language.
Note: Draw and fill the following table in your answer sheet:
Sample Regular Expression
a. Σ ={a, b} Only words with exactly two consecutive b's [1 marks]
Solution:
Sample = {bb, bba, abb, abba, aabbaaa …..}
a*bba*
b. Σ ={a, b} Empty words or words that do not end with ab. [2 marks]
Solution:
Sample= { Λ, a,b, abb, aa, ba, bbb,….. }
Λ + b+ ((a + b)*(a + bb))
c. Σ ={a, b} Only words such that { an
bm
| n is even and m is odd} where n and m indicate number
of “a”s and “b”s respectively. [2 marks]
Solution:
Sample = {b,aab,aabbb,..}
(aa)* b(bb)*
(aa+bb)* b
d. Σ ={a, b} Only words such that { an
bm
| (n+m) is even }; where n and m indicate number of “a”s
and “b”s respectively. Note that an even number could be sum of two even numbers or of two
odd numbers. [3 marks]
Solution:
Sample = {Λ, ab, aabb, aaabbb...}
(aa)* (bb)* + (aa)* a (bb)* b
e. Σ ={a, b} Words where “a” appears ONLY in even positions or doesn’t appear at all.
[3 marks]
Solution:
Sample = { Λ b ba bbb bbba baba …..}
- b+(bb+ba)*b*
- (ba+b)*
- (b(bb)* a)* + ( b(bb)*)*
f. Σ ={a, b} Construct a regular expression for all strings that have exactly one double letter in
them. “One double letter” implies two equal touching letters; triples or more are excluded.
[4 marks]
Solution:
Sample = { aa, baa, …..}
(b + Λ)(ab)*aa(ba)*(b + Λ) + (a + Λ)(ba)*bb(ab)*(a + Λ)
Page 2 of 5
Question 2[mandatory] [10 marks]
For each of the following languages do the following:
i. Understand the languages without any assistance;
ii. Write sample words for the language where you show the smallest possible
word.
iv. Draw a deterministic finite automaton that represents the language and
handles incorrect inputs.
a. Σ = {a, b} words where “a” appears ONLY in the second position or doesn’t appear at all.
[2 marks]
Solution:
Sample = { Λ b ba bbb bab babbb …..}
b. Σ = {a, b} Words that begin and ending with the same letter. [4 marks]
Solution:
Sample = { Λ b ba bbb bab babbb …..}
a
b
b
-+1 2
a,b
+3
a
a
-+1
b
4
a
b
3
a
+2
b
b
a
a
5
b
+4
Page 3 of 5
c. Prove that the language an
bn
is not regular using pumping lemma. [4 marks]
Solution:
If L is regular, then by Pumping Lemma (P.L.) ∃ n such that . . .
Now let x = 0n
1n
s ∈ L and |s| ≥ n, so by P.L. ∃x, y , z
then x = 0n
1n
= xyz with |xy| ≤ n and |y| ≥ 1.
But then (4) fails for i = 0:
So, x = 0s
, y = 0t
, z = 0p
1n
with
s + t ≤ n, t ≥ 1, p≥ 0, s+ t + p = n.
fails for i = 0: mean that t = 0 , then s+p not = n and number of 0 will be greater than
number of 1 and language will be not regular
Solve three of the next four questions
Question 3 [12 marks]
a. Σ ={a, b}. Describe “anything aa anything” “(a+b)*aa(a+b)*” using CFG. [6 marks]
Solution:-
(a+b)*aa(a+b)*
1 S à XaaX
2) X à aX
3) X à bX
4) X à Λ
Textbook Reference: Page 234
b. Derive “baabaab” from the above grammar. [6 marks]
Note: Draw and fill the following table in your answer sheet:
Derivation Rule Number
Solution:-
S à XaaX [by 1]
X à bXaaX [by 3]
X à bᴧaaX [by 4]
X à baabX [by 3]
X à baabaX [by 2]
X à baabaaX [by 2]
X à baabaabX [by 3]
X à baabaabΛ [by 4]
Textbook Reference: Page 234
Question 4 [12 marks]
PDA superceed FA by having a memory in form of stack hence it can handle
recursive structures.
a. Create a diagram for a PDA that can parse the CFG: [6 marks]
S→(S)|a
b. Trace the PDA on input “(a)” [6 marks]
Page 4 of 5
State Stack Tape
Start Δ….. (a)Δ…..
READ1 Δ…… (a)Δ…..
PUSH ( (Δ……. (a)Δ…..
READ1 (Δ……. (a)Δ…..
POP ) (Δ……. (a)Δ…..
Question 5 [12 marks]
a. Construct a TM that accepts all words with ‘b’ as a second letter. [6 marks]
Solution:
b. Write down the tracing table of aba for the above TM. [6 marks]
Note: Draw and fill the following table in your answer sheet:
Input string
(underline the letter that the head is reading)
State Number
2Start 1
Reject 5
Accept 4
(a, a, R)
(b, b, R)
(b, b, R)
(a, a, R)
PUSH ( READ2READ1
POP3
POP2
START
ACCEPT
( a )
(
(
(a, a, R)
(b, b, R)
)
Page 5 of 5
Solution:
Input string
(underline the letter the the head is reading)
State Number
aba 1
aba 2
aba 4 Accept
Question 6 [12 marks]
a) Given the following table for some problems, write down the class of the problem [Class
P, Class NP]: [6 marks]
Problem complexity Class
heap sort n log n
linear sort n3
Linear search n2
quick sort n log n
Creating a schedule for m football matches for n teams. 2m*n
Traveling sales man visiting n cities n! (n factorial)
3 Cars need to visit n customers only once with the least cost. 3n
check if a number is prime for a number n n/4
Composite Sum for a number n n-1
Does m clauses with n boolean variables has an assignment that makes
the whole expression TRUE
2m*n
Solution:
Problem complexity Class
heap sort n log n N
linear sort n3
N
Linear search n2
N
quick sort n log n N
Creating a schedule for m football matches for n teams. 2m*n
NP
Traveling sales man visiting n cities n! (n factorial) NP
3 Cars need to visit n customers only once with the least cost. 3n
NP
check if a number is prime for a number n n/4 N
Composite Sum for a number n n-1 N
Does m clauses with n boolean variables has an assignment that makes
the whole expression TRUE
2m*n
NP
b) Given the following instance of SAT: [6 marks]
SAT= (a ν	
  b)	
  Λ	
  (¬b ν	
  c)	
  Λ	
  (¬a ν¬b)	
  
i) Construct a table that solves the problem.
ii) Does this problem have a valid solution?
Solution:
a b c a∨b ¬b∨c ¬a∨¬b SAT
T T T T T F F
T T F T F F F
T F T T T T T
T F F T T T T
F T T T T T T
F T F T F T F
F F T F T T F
F F F F T T F
SignatureNameExaminers
Examiner 1
Examiner 2

Más contenido relacionado

La actualidad más candente

Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersappasami
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfaSampath Kumar S
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automatahafizhamza0322
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 
Generalized transition graphs
Generalized transition graphsGeneralized transition graphs
Generalized transition graphsArham Khan G
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory Rajendran
 
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
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsShiraz316
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplicationMegha V
 

La actualidad más candente (20)

Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papers
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa
 
Finite automata
Finite automataFinite automata
Finite automata
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
Generalized transition graphs
Generalized transition graphsGeneralized transition graphs
Generalized transition graphs
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
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
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Lesson 04
Lesson 04Lesson 04
Lesson 04
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
2 homework
2 homework2 homework
2 homework
 
LISP:Control Structures In Lisp
LISP:Control Structures In LispLISP:Control Structures In Lisp
LISP:Control Structures In Lisp
 

Destacado (9)

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
 
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
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
 
Operating system notes
Operating system notesOperating system notes
Operating system notes
 
Os solved question paper
Os solved question paperOs solved question paper
Os solved question paper
 
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...
 

Similar a Model answer of exam TC_spring 2013

College Algebra MATH 107 Spring, 2015, V4.8 Page 1 of .docx
College Algebra   MATH 107   Spring, 2015, V4.8 Page 1 of .docxCollege Algebra   MATH 107   Spring, 2015, V4.8 Page 1 of .docx
College Algebra MATH 107 Spring, 2015, V4.8 Page 1 of .docxmonicafrancis71118
 
Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016appasami
 
Simplifying algebraic expressions
Simplifying algebraic expressionsSimplifying algebraic expressions
Simplifying algebraic expressionsMalini Sharma
 
Cs6503 theory of computation april may 2017
Cs6503 theory of computation april may 2017Cs6503 theory of computation april may 2017
Cs6503 theory of computation april may 2017appasami
 
Software product selectionSelecting a software product for use i.docx
Software product selectionSelecting a software product for use i.docxSoftware product selectionSelecting a software product for use i.docx
Software product selectionSelecting a software product for use i.docxwhitneyleman54422
 
College Algebra MATH 107 Spring, 2020Page 1 of 11 MA.docx
College Algebra   MATH 107 Spring, 2020Page 1 of 11 MA.docxCollege Algebra   MATH 107 Spring, 2020Page 1 of 11 MA.docx
College Algebra MATH 107 Spring, 2020Page 1 of 11 MA.docxmary772
 
regular expressions (Regex)
regular expressions (Regex)regular expressions (Regex)
regular expressions (Regex)Rebaz Najeeb
 
College Algebra MATH 107 Spring, 2016, V4.7 Page 1 of .docx
College Algebra   MATH 107   Spring, 2016, V4.7 Page 1 of .docxCollege Algebra   MATH 107   Spring, 2016, V4.7 Page 1 of .docx
College Algebra MATH 107 Spring, 2016, V4.7 Page 1 of .docxclarebernice
 
All homework and exams in one file.pdf
All homework and exams in one file.pdfAll homework and exams in one file.pdf
All homework and exams in one file.pdfAnn Wera
 
Hw4 2017-spring
Hw4 2017-springHw4 2017-spring
Hw4 2017-spring奕安 陳
 
Mid module review
Mid module reviewMid module review
Mid module reviewmlabuski
 
Units 1 3 review
Units 1 3 reviewUnits 1 3 review
Units 1 3 reviewmlabuski
 

Similar a Model answer of exam TC_spring 2013 (20)

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
 
College Algebra MATH 107 Spring, 2015, V4.8 Page 1 of .docx
College Algebra   MATH 107   Spring, 2015, V4.8 Page 1 of .docxCollege Algebra   MATH 107   Spring, 2015, V4.8 Page 1 of .docx
College Algebra MATH 107 Spring, 2015, V4.8 Page 1 of .docx
 
Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016
 
Simplifying algebraic expressions
Simplifying algebraic expressionsSimplifying algebraic expressions
Simplifying algebraic expressions
 
Cs6503 theory of computation april may 2017
Cs6503 theory of computation april may 2017Cs6503 theory of computation april may 2017
Cs6503 theory of computation april may 2017
 
Software product selectionSelecting a software product for use i.docx
Software product selectionSelecting a software product for use i.docxSoftware product selectionSelecting a software product for use i.docx
Software product selectionSelecting a software product for use i.docx
 
3D Represent.docx
3D Represent.docx3D Represent.docx
3D Represent.docx
 
College Algebra MATH 107 Spring, 2020Page 1 of 11 MA.docx
College Algebra   MATH 107 Spring, 2020Page 1 of 11 MA.docxCollege Algebra   MATH 107 Spring, 2020Page 1 of 11 MA.docx
College Algebra MATH 107 Spring, 2020Page 1 of 11 MA.docx
 
regular expressions (Regex)
regular expressions (Regex)regular expressions (Regex)
regular expressions (Regex)
 
Cs 73
Cs 73Cs 73
Cs 73
 
College Algebra MATH 107 Spring, 2016, V4.7 Page 1 of .docx
College Algebra   MATH 107   Spring, 2016, V4.7 Page 1 of .docxCollege Algebra   MATH 107   Spring, 2016, V4.7 Page 1 of .docx
College Algebra MATH 107 Spring, 2016, V4.7 Page 1 of .docx
 
Vectors
VectorsVectors
Vectors
 
All homework and exams in one file.pdf
All homework and exams in one file.pdfAll homework and exams in one file.pdf
All homework and exams in one file.pdf
 
Hw4 2017-spring
Hw4 2017-springHw4 2017-spring
Hw4 2017-spring
 
Mid module review
Mid module reviewMid module review
Mid module review
 
Adobe
AdobeAdobe
Adobe
 
A.B. .docx
A.B. .docxA.B. .docx
A.B. .docx
 
Lesson 09.ppt
Lesson 09.pptLesson 09.ppt
Lesson 09.ppt
 
Units 1 3 review
Units 1 3 reviewUnits 1 3 review
Units 1 3 review
 
CV2005_3Lec02.ppt
CV2005_3Lec02.pptCV2005_3Lec02.ppt
CV2005_3Lec02.ppt
 

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 Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
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

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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
 
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
 
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
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Último (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
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
 
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
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Model answer of exam TC_spring 2013

  • 1. Page 1 of 5 Cairo University Faculty of Computers and Information Postgraduate Final Exam (Pre-masters) Department : Computer science Lecturer : Dr. Hussien Sharaf Course : Theory of computation Course Code : CS611 Marks : 60 marks Date : 1-June-2013 Time : 2 hours Solve only five questions, given that questions one and two are mandatory: Question 1[mandatory] [15 marks] For each of the following languages do the following: i. Understand the languages without any assistance; ii. Write sample words for the language where you show the smallest possible word. iii. Construct a regular expression that represents the language. Note: Draw and fill the following table in your answer sheet: Sample Regular Expression a. Σ ={a, b} Only words with exactly two consecutive b's [1 marks] Solution: Sample = {bb, bba, abb, abba, aabbaaa …..} a*bba* b. Σ ={a, b} Empty words or words that do not end with ab. [2 marks] Solution: Sample= { Λ, a,b, abb, aa, ba, bbb,….. } Λ + b+ ((a + b)*(a + bb)) c. Σ ={a, b} Only words such that { an bm | n is even and m is odd} where n and m indicate number of “a”s and “b”s respectively. [2 marks] Solution: Sample = {b,aab,aabbb,..} (aa)* b(bb)* (aa+bb)* b d. Σ ={a, b} Only words such that { an bm | (n+m) is even }; where n and m indicate number of “a”s and “b”s respectively. Note that an even number could be sum of two even numbers or of two odd numbers. [3 marks] Solution: Sample = {Λ, ab, aabb, aaabbb...} (aa)* (bb)* + (aa)* a (bb)* b e. Σ ={a, b} Words where “a” appears ONLY in even positions or doesn’t appear at all. [3 marks] Solution: Sample = { Λ b ba bbb bbba baba …..} - b+(bb+ba)*b* - (ba+b)* - (b(bb)* a)* + ( b(bb)*)* f. Σ ={a, b} Construct a regular expression for all strings that have exactly one double letter in them. “One double letter” implies two equal touching letters; triples or more are excluded. [4 marks] Solution: Sample = { aa, baa, …..} (b + Λ)(ab)*aa(ba)*(b + Λ) + (a + Λ)(ba)*bb(ab)*(a + Λ)
  • 2. Page 2 of 5 Question 2[mandatory] [10 marks] For each of the following languages do the following: i. Understand the languages without any assistance; ii. Write sample words for the language where you show the smallest possible word. iv. Draw a deterministic finite automaton that represents the language and handles incorrect inputs. a. Σ = {a, b} words where “a” appears ONLY in the second position or doesn’t appear at all. [2 marks] Solution: Sample = { Λ b ba bbb bab babbb …..} b. Σ = {a, b} Words that begin and ending with the same letter. [4 marks] Solution: Sample = { Λ b ba bbb bab babbb …..} a b b -+1 2 a,b +3 a a -+1 b 4 a b 3 a +2 b b a a 5 b +4
  • 3. Page 3 of 5 c. Prove that the language an bn is not regular using pumping lemma. [4 marks] Solution: If L is regular, then by Pumping Lemma (P.L.) ∃ n such that . . . Now let x = 0n 1n s ∈ L and |s| ≥ n, so by P.L. ∃x, y , z then x = 0n 1n = xyz with |xy| ≤ n and |y| ≥ 1. But then (4) fails for i = 0: So, x = 0s , y = 0t , z = 0p 1n with s + t ≤ n, t ≥ 1, p≥ 0, s+ t + p = n. fails for i = 0: mean that t = 0 , then s+p not = n and number of 0 will be greater than number of 1 and language will be not regular Solve three of the next four questions Question 3 [12 marks] a. Σ ={a, b}. Describe “anything aa anything” “(a+b)*aa(a+b)*” using CFG. [6 marks] Solution:- (a+b)*aa(a+b)* 1 S à XaaX 2) X à aX 3) X à bX 4) X à Λ Textbook Reference: Page 234 b. Derive “baabaab” from the above grammar. [6 marks] Note: Draw and fill the following table in your answer sheet: Derivation Rule Number Solution:- S à XaaX [by 1] X à bXaaX [by 3] X à bᴧaaX [by 4] X à baabX [by 3] X à baabaX [by 2] X à baabaaX [by 2] X à baabaabX [by 3] X à baabaabΛ [by 4] Textbook Reference: Page 234 Question 4 [12 marks] PDA superceed FA by having a memory in form of stack hence it can handle recursive structures. a. Create a diagram for a PDA that can parse the CFG: [6 marks] S→(S)|a b. Trace the PDA on input “(a)” [6 marks]
  • 4. Page 4 of 5 State Stack Tape Start Δ….. (a)Δ….. READ1 Δ…… (a)Δ….. PUSH ( (Δ……. (a)Δ….. READ1 (Δ……. (a)Δ….. POP ) (Δ……. (a)Δ….. Question 5 [12 marks] a. Construct a TM that accepts all words with ‘b’ as a second letter. [6 marks] Solution: b. Write down the tracing table of aba for the above TM. [6 marks] Note: Draw and fill the following table in your answer sheet: Input string (underline the letter that the head is reading) State Number 2Start 1 Reject 5 Accept 4 (a, a, R) (b, b, R) (b, b, R) (a, a, R) PUSH ( READ2READ1 POP3 POP2 START ACCEPT ( a ) ( ( (a, a, R) (b, b, R) )
  • 5. Page 5 of 5 Solution: Input string (underline the letter the the head is reading) State Number aba 1 aba 2 aba 4 Accept Question 6 [12 marks] a) Given the following table for some problems, write down the class of the problem [Class P, Class NP]: [6 marks] Problem complexity Class heap sort n log n linear sort n3 Linear search n2 quick sort n log n Creating a schedule for m football matches for n teams. 2m*n Traveling sales man visiting n cities n! (n factorial) 3 Cars need to visit n customers only once with the least cost. 3n check if a number is prime for a number n n/4 Composite Sum for a number n n-1 Does m clauses with n boolean variables has an assignment that makes the whole expression TRUE 2m*n Solution: Problem complexity Class heap sort n log n N linear sort n3 N Linear search n2 N quick sort n log n N Creating a schedule for m football matches for n teams. 2m*n NP Traveling sales man visiting n cities n! (n factorial) NP 3 Cars need to visit n customers only once with the least cost. 3n NP check if a number is prime for a number n n/4 N Composite Sum for a number n n-1 N Does m clauses with n boolean variables has an assignment that makes the whole expression TRUE 2m*n NP b) Given the following instance of SAT: [6 marks] SAT= (a ν  b)  Λ  (¬b ν  c)  Λ  (¬a ν¬b)   i) Construct a table that solves the problem. ii) Does this problem have a valid solution? Solution: a b c a∨b ¬b∨c ¬a∨¬b SAT T T T T T F F T T F T F F F T F T T T T T T F F T T T T F T T T T T T F T F T F T F F F T F T T F F F F F T T F SignatureNameExaminers Examiner 1 Examiner 2