1310 1948 PDF
1310 1948 PDF
1310 1948 PDF
I Daniyal Akram Registration No. 18-ARID-369, hereby declare that I will not be involved
Term Examination 2020. I take full responsibility of my conduct. If I found involved in any
kind of such activity of cheating/copying/plagiarizing then Institute reserves the right to take
Student Signature
Mid Exam / spring 2020 (Paper Duration 24 hours)
To be filled by Teacher
To be filled by Student
Q.No.1.
a) What is the difference between FA, TG, and GTG? (Mark=01)
Answer:
FA:
● It stands for Finite Automata.
● It is a simple idealized machine used to recognize patterns.
● Example: Consider the language L of strings defined over Σ={a, b}, starting with b.
The L may be expressed by RE b(a + b)*, may be accepted by the following FA:
TG:
● It stands for Transition Graph.
● It is a collection of three things: a finite set of states, alphabet Σ of possible input
letters from which input strings are formed, and finite set of transitions.
● Example: Consider the Language L defined over Σ = {a, b} of all strings including Λ.
The language L may be accepted by the following TG:
GTG:
● It stands for Generalized Transition Graph.
● It is a transition graph whose edges are labeled with regular expressions or string of
input alphabets rest part of the graph is same as the usual transition graph.
● Example: Consider the language L of strings defined over Σ = {a,b}, containing double
a or double b. The language L can be expressed by the following regular expression
(a+b) * (aa + bb) (a+b)*. The language L may be accepted by the following GTG:
Difference:
Transition Graphs (TGs) and Generalized Transition Graphs (GTGs) provide some
relaxations. It is possible that there may exist more than one path or there may not be any
path for a certain string. This property is called non-determinism and can help in
differentiating FA, TG, and GTG from each other.
Hence, FA is also called a DFA. In GTG, directed edges connecting with some pair of states
are labeled with regular expression.
b) Determine RE corresponding to the following TG. Show all steps.
(Marks=02)
Answer:
Step No. 01: Eliminating states 7, 8, 10, and 11.
(RE.2)
New States after reading
Old States a b
z1+=(p,1) (q,2) = z4 (p,1) = z1
z2+= (p,2) (q,1) = z3 (p,2) = z2
z3+=(q,1) (r,2) = z6 (p,1) = z1
z4+=(q,2) (r,1) = z5 (p,2) = z2
z5=(r,1) (r,2) = z6 (r,1) = z5
z6+=(r,2) (r,1) = z5 (r,2) = z6
FA for RE.1c and RE.2c:
FA for (RE.1cRE.2c)c
Q.No.2.
a) Convert the following Non-Deterministic Finite Automata (NFA) to Deterministic
Finite Automata (DFA)
(Marks=1.5)
Answer:
b) Convert the following Non-Deterministic Finite Automata (NFA) to Deterministic
Finite Automata (DFA) (Marks=1.5)
Answer:
c) Convert the following NFA-˄ into FA. Draw Transition table corresponding to
required FA
(Marks=02)
Answer:
Transition table for given NFA is:
δ 0 1 λ
1 Ø Ø 2,6
2 Ø 3 Ø
3 Ø Ø 4
4 5 Ø Ø
5 Ø Ø 2,6
6 Ø Ø Ø
Q.No.3.
Answer:
Required NFA is:
b) Write down the tuples of DFA and NFA (Marks=1.5)
Answer:
Tuples of DFA:
DFA is represented by following tuples:
1) 0 is the starting state.
2) is a finite set of states.
3) is a finite set of symbols.
4) is the transition function for input symbols.
5) is a subset of .
Tuples of NFA:
NFA is represented by following tuples:
1) is finite set of states.
2) is a finite set of inputs.
3) is the transition function.
4) 0 is the starting state.
5) is a finite state.
c) Design a DFA such that: L = {anbmcl | n,m,l ≥ 0} Given: Input alphabet, Σ={a, b, c}
(Marks=1.5)
Answer:
d) Write the regular expression for the language containing the string in which every 0 is
immediately followed by 11. (Marks=0.5)
Answer:
The regular expression is:
R. E. = 011 + 1 ∗
e) All strings in which the total number of a's is divisible by three (Marks=0.5)
Answer:
For example, aabaabbaba.
b∗ ab∗ ab∗ab∗ ∗
f) All strings that have an even number of a's and an odd number of b's. (Marks=0.5)
Answer:
∗
aa + bb + ab + ba aa + bb ∗ ab + ba
g) Construct a regular expression for all strings in which the letter b is never tripled. This means that
no word contains the substring bbb Marks=0.5)
λ + b + bb a + ab + abb
Answer:
∗