A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}.

Q. A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}.

𝑇1:   π‘Ž? (𝑏|𝑐)βˆ—π‘Ž

𝑇2:   π‘? (π‘Ž|𝑐)βˆ—π‘

𝑇3:Β   𝑐? (𝑏|π‘Ž)βˆ—π‘

Note that β€˜x?’ means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.

If the string π‘π‘π‘Žπ‘Žπ‘π‘Žπ‘π‘ is processed by the analyzer, which one of the following is the sequence of tokens it outputs?

(A) 𝑇1𝑇2𝑇3Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  (B) 𝑇1𝑇1𝑇3Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  (C) 𝑇2𝑇1𝑇3Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  (D) 𝑇3𝑇3

Ans: 𝑇3𝑇3

Sol:

0 or 1 occurrence of the symbol x.   T1 : (b+c)* a + a(b+c)* a T2 : (a+c)* b + b(a+c)* b T3 : (b+a)* c + c(b+a)* c Given String : bbaacabc Longest matching prefix is \” bbaac \” (Which can be generated by T3) The remaining part (after Prefix) \”abc\” (Can be generated by T3) So, the answer is T3T3 

Take Mock Tests

Government Schemes Mock Test Start Test!
Political Science Mock Test – 42 Start Test
History Test – 190 Start Test
Quantitative Aptitude Test Start Test!
Data Interpretation - Mock Test Start Test!
General Awareness - Mock Test Start Test!
Reasoning Ability - Mock Test Start Test!
We will be happy to hear your thoughts

Leave a reply

Gkseries.com
Logo
Register New Account