Open In App
Related Articles

GATE | GATE CS 2018 | Question 65

Improve Article
Improve
Save Article
Save
Like Article
Like

A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}. T1: a?(b∣c)*a T2: b?(a∣c)*b T3: c?(b∣a)*c 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 bbaacabc is processes by the analyzer, which one of the following is the sequence of tokens it outputs?

(A)

T1T2T3

(B)

T1T1T3

(C)

T2T1T3

(D)

T3T3


Answer: (D)

Explanation:

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 


Quiz of this Question
Please comment below if you find anything wrong in the above post

Last Updated : 01 Sep, 2021
Like Article
Save Article
Similar Reads