COMPILER DESIGN

LEXICAL ANALYSIS

REGULAR EXPRESSIONS AND FINITE AUTOMATA

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
According to the given transitions, which among the following are the epsilon closures of q1 for the given NFA? (q1, ) = {q2, q3, q4} (q4, 1) =q1 (q1, ) =q1
A
q4
B
q2
C
q1
D
q1, q2, q3, q4
Explanation: 

Detailed explanation-1: -According to the given transitions, which among the following are the epsilon closures of q1 for the given NFA? (q1, ) = q2, q3, q4 (q4, 1) =q1 (q1, ) =q1a)q4b)q2c)q1d)q1, q2, q3, q4Correct answer is option ‘D’.

Detailed explanation-2: --closure (q1)= q1, q2 q1 is self-state and q2 is a state obtained from q1 with epsilon input. -closure (q2)= q2

Detailed explanation-3: -The epsilon closure E(q) of a state q in Q is the union of the set q with the set of all states that can be reached from q via one or more transitions. If R is a set of states from Q, the epsilon closure E(R) is defined as the union of the epsilon closures of all the states in R.

Detailed explanation-4: -Which of the following belongs to the epsilon closure set of a? Explanation: The epsilon closure of the set q is the set that contains q, together with all the states which can be reached starting at q by following only epsilon transitions. Explanation: The epsilon closure set of f2 consist of the elements:f2, f3.

Detailed explanation-5: -Solution: Let us obtain -closure of each state. Now, let -closure q0 = q0, q1, q2 be state A. ’(A, 0) = -closure ((q0, q1, q2), 0) = -closure (q0, 0) ∪ (q1, 0) ∪ (q2, 0) = -closure q3 = q3 call it as state B.

There is 1 question to complete.