Pir Mehr Ali Shah
Arid Agriculture University, Rawalpindi
Office of the controller of Examinations
Mid Exam Spring 2021 (Paper Duration 12 hours)
To be filled by Teacher
Course No.: …… CS-536 ……Course Title:… Theory of Automata and Formal Languages……
Total Marks:……….……18………………Date of Exam:…………………30/4/2021……………............................
Degree: ……………BSCS………………….Semester:…………4……………… Section:…………………C…………………
Marks
Q. No. 1 2 3 4 5 6 7 8 9 10 Obtained/
TotalMarks
Marks
Obtaine
d
Total Marks in Words:
Name of the teacher:
Who taught the course: Signature of teacher / Examiner:
To be filled by Student
Registration No.: …19-ARID-5148……….……… Name:……Ayesha Musarat………………
Answer the following questions.
Question.No.1 Let Σ= {Ac,BA,bcb,cd,ab,f,d,e}.
(a) Identify valid strings and Find the length of the valid given below strings (1+1+1)
1)fefBAfbcbcdAcfab
2)BAeffBAAcbcbab
3)bcbefabfABAAceddbcb
Answer:
1:
S= fefBAfbcbcdAcfab
Factoring= (f),(e),(f),(BA),(f),(bcb),(cd),(Ac),(f),(ab)
|S| = 10
10 is valid string
2:
S= BAeffBAAcbcbab
Factoring = (BA),(e),(f),(f),(BA),(Ac),(bcb),(ab)
|S| = 8
8 is Valid string
3:
S= bcbefabfABAAceddbcb
Factoring = (bcb),(e),(f),(ab),(f),(BA),(Ac),(e),(d),(d),(bcb)
|S| =11
11 is valid string
Q.No.2 Define following through descriptive definition
(a)The language { ap bm cp de} of strings defined over Σ={a,b,c}, as m=odd number, p= prime
numbers , e =even (2)
(b) The language L of strings that start with bba and end with abc, defined over Σ={a,b,c}, what will
be the minimum length string. (2+1)
Answer:
L={aabccdd,aaabbbccdd,aaabbbcccdddd,aaabbbcccccdd,aaaaabbbbbcccccdd,aaaaaaabbbbbbbcccccdd
dd………}
Here we have defined language set by given condition where number of a's must be prime , number of
b's must be odd , number of c's must be prime , number of d's must be even in language . As we can
see in above language set first language item is aabccdd where number of a = 2 (prime) , number of b
= 1(odd) , number of c = 2(prime) , number of d = 2(even) .
(b) : The Language L of strings that starts with bba and end with abc defined over { a , b , c } .
Minimum length string will be of 6 and the minimum length string will be bbaabc which starts from
bba and end with abc .
L={bbababc,bbacabc,bbaaabc,bbaaaabc,bbabbabc….}
Minimum length string = bbababc,bbacabc,bbaaabc
Q.No.3
(a) Define through recursive definition , The language L of strings that start and end with different
latters and also must contain aa in middle of each string, defined over Σ={a,b,c}. also Write at least 2
Valid and 2 Invalid strings belongs to this language (2+2)
(b) Write the Regular expression for the language which accept no pair of consecutive a’s over Σ
={a,b} (1+1+1)
i.R.E= ______________ (1)
ii.3 Valid strings= _______________(1)
iii.3 Invalid strings= _________________(1)
(c) Construct a DFA which accepts all strings over Σ ={a,b} in which second last symbol is a and last
symbol is b. also Write at least 2 Valid and 2 Invalid strings for the designed DFA. (2+1)
Answer:
a) 2 valid strings; babaabbc, cabaabcb
2 Invalid String: abba, bbbbb
b)
i. RE: (b + ab)* (a + λ)
ii. 3 valid stirngs: ab, aba, bab
iii. 3 invalid stirngs: aa, bababaa, baaba
c)
2 Valid Strings; aaab, bababaaab
2 Invalid String: a,b, bb, bababb