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?

This question was previously asked in
GATE CS 2018 Official Paper
View all GATE CS Papers >
  1. 𝑇1𝑇2𝑇3
  2. 𝑇1𝑇1𝑇3
  3. 𝑇2𝑇1𝑇3
  4. 𝑇3𝑇3

Answer (Detailed Solution Below)

Option 4 : 𝑇3𝑇3
Free
GATE CS Full Mock Test
5.3 K Users
65 Questions 100 Marks 180 Mins

Detailed Solution

Download Solution PDF

Concept:

Take relational algebra which generates the longest subsequence.

With  T3 we get a subsequence of 5, and T1 we get a subsequence of only 4, T2 we get a subsequence of only 3.

Hence, T3 preferred over Tand T1

Explanation

String = π‘π‘π‘Žπ‘Žπ‘π‘Žπ‘π‘

(𝑏|π‘Ž)∗ = (a + b)*

𝑐? = (Ο΅ + c)

𝑇3𝑐? (𝑏|π‘Ž)∗𝑐

T3 = bbaac (longest prefix match)

T3= abc

𝑇3𝑇3 = π‘π‘π‘Žπ‘Žπ‘ π‘Žπ‘π‘

Therefore option 4 is correct

Latest GATE CS Updates

Last updated on Jan 8, 2025

-> GATE CS 2025 Admit Card has been released on 7th January 2025.

-> The exam will be conducted on 1st February 2025 in 2 shifts.

-> Candidates applying for the GATE CE must satisfy the GATE Eligibility Criteria.

-> The candidates should have BTech (Computer Science). Candidates preparing for the exam can refer to the GATE CS Important Questions to improve their preparation.

-> Candidates must check their performance with the help of the GATE CS mock tests and GATE CS previous year papers for the GATE 2025 Exam.

Get Free Access Now
Hot Links: teen patti master online teen patti all teen patti rummy 51 bonus teen patti download apk