0% found this document useful (0 votes)
34 views

Practice Questions Modules 2 Answer

Uploaded by

pragyaruchisood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Practice Questions Modules 2 Answer

Uploaded by

pragyaruchisood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

(SE, AI, DS, CTIS, MACT, IOT)


21CIC44-Theory of Computation
Assignment-2

# Question COs Marks RBTL

1 Define the following 1 5 each 1,2

a. Regular expression

b. Regular grammar
2 Design a FA from given regular expression 10 + (0 + 11)0* 1. 1 5 each 1,2

Step 1:

Step 2:
Step 3:

Step 4:

Step 5:
3. What is a Regular Expression? Given a language, find a Regular 1 5 each 1,2
Expression for the following:
i)L = {w ɛ {a, b} *: |w| is even}.

ii)L = {w ɛ {a, b} *: w contains odd number of a’s}.

iii)L = {0n 1m 2n | n, m >= 1}

iv)L = {anbm: m >= 2, n <= 4 }

v)L = {a2n + 1 b2m: m >= 0, n >= 0}


vi)L ={ anbm: m <= 3, n >= 4 }

vii)L ={a2n b2m + 1: m >= 0, n >= 0}

2. Write Regular expression for the following languages 1,2 6 1,2

i)The set of all strings over ∑ = {a, b, c} containing at least one a and at
least one b

ii)Set of all strings that contains alternating 0’s and 1’s


iii)Set of strings of a’s and b’s of odd length

3. Convert the following automaton to a regular expression using “State 1,2 6 1,2

Elimination Technique”

a
c.
d
e
4. Build a Regular Expression from an FSM using Arden’s theorem 1,2 6 1,2
5. Construct the regular expression for the given DFA using Arden’s 1,2 8 1,2
theorem
6. 1,2 8 1,2
Construct the regular expression for the given DFA Arden’s theorem
7. Construct the regular expression for the given DFA using Arden’s 1,2 5 1,2
theorem

q1 = q1 0 + ε

Since q1 is the start state, so ε will be added, and the input 0 is


coming to q1 from q1 hence we write
State = source state of input × input coming to it

Similarly,

q2 = q1 1 + q2 1
q3 = q2 0 + q3 (0+1)
Since the final states are q1 and q2, we are interested in solving q1
and q2 only. Let us see q1 first

q1 = q1 0 + ε

We can re-write it as

q1 = ε + q1 0

Which is similar to R = Q + RP, and gets reduced to R = OP*.

Assuming R = q1, Q = ε, P = 0

We get

q1 = ε.(0)*
q1 = 0* (ε.R*= R*)
Substituting the value into q2, we will get

q2 = 0* 1 + q2 1
q2 = 0* 1 (1)* (R = Q + RP → Q P*)

The regular expression is given by

r = q1 + q2
= 0* + 0* 1.1*
r = 0* + 0* 1+ (1.1* = 1+)
8. i)Convert Finite automata into Regular Grammar 1,2 8 1,2
ii)Convert Regular Grammar into Finite automata
S→0A | 1A
A→0A | 1A| +B |-B
B→0B | 1B | 0 | 1

9. Draw NFA for the Regular Expression (using Thomas rules) 1 6 1


i.) a(a+b) *ab
ii.) (a/b) *abb

iii) (0+1) *(00/11)

iv)4(1+2) *11(1/2)

10 Explain Moore machine with example. 1 5 1


11 Explain Mealy machine with example. 1 5 1

12 Convert the following Moore machine into a Mealy machine: 1 5 1


i)
ii)
13 Prove that the given language L is not regular Let L = {a nb n: n ≥ 1}. 1 5 1
14. Prove that the given language L is not regular Let L = {a nb2 n : n ≥ 1}. 1 6 1
15. State and Prove Pumping Theorem for Regular Languages 1 6 1
`
16. Explain the closure properties of Regular languages 1 10 1
Closure properties on regular languages are defined as certain operations
on regular language which are guaranteed to produce regular language.
Closure refers to some operation on a language, resulting in a new
language that is of same “type” as originally operated on i.e., regular.
Regular languages are closed under following operations. Consider L
and M are regular languages:

Kleen Closure: RS is a regular expression whose language is L, M. R* is


a regular expression whose language is L*.
Positive closure: RS is a regular expression whose language is L, M. R^+
is a regular expression whose language is L^+ .
Complement: The complement of a language L (with respect to an
alphabet E such that E^* contains L) is E^* –L. Since E^* is surely
regular, the complement of a regular language is always regular.
Reverse Operator: Given language L, L^R is the set of strings whose
reversal is in L. Example: L = {0, 01, 100}; L^R ={0, 10, 001}. Proof:
Let E be a regular expression for L. We show how to reverse E, to provide
a regular expression E^R for L^R .
Union: Let L and M be the languages of regular expressions R and S,
respectively.Then R+S is a regular expression whose language is(L U
M).
Intersection: Let L and M be the languages of regular expressions R and
S, respectively then it a regular expression whose language is L
intersection M. proof: Let A and B be DFA’s whose languages are L and
M, respectively. Construct C, the product automaton of A and B make the
final states of C be the pairs consisting of final states of both A and B.
Set Difference operator: If L and M are regular languages, then so is L –
M = strings in L but not M. Proof: Let A and B be DFA’s whose languages
are L and M, respectively. Construct C, the product automaton of A and B
make the final states of C be the pairs, where A-state is final but B-state is
not.
Homomorphism: A homomorphism on an alphabet is a function that
gives a string for each symbol in that alphabet. Example: h(0) = ab; h(1) =
E . Extend to strings by h(a1…an) =h(a1)…h(an). Example: h(01010) =
ababab. If L is a regular language, and h is a homomorphism on its
alphabet, then h(L)= {h(w) | w is in L} is also a regular language. Proof:
Let E be a regular expression for L. Apply h to each symbol in E. Language
of resulting R, E is h(L).
Inverse Homomorphism : Let h be a homomorphism and L a language
whose alphabet is the output language of h. h^-1 (L) = {w | h(w) is in L}.

You might also like