Open In App

GATE | GATE CS Mock 2018 | Question 34

Like Article
Like
Save
Share
Report

Consider the following context-free grammar over the alphabet ∑ = {a, b} with S as the start symbol:

S → AT 
A → aAa | bAb | #T 
T → aT | bT | λ 

Which of the following represents the language generated by the above grammar?
(A) { w#x | w^R is a substring of x, where w, x ∈ {a, b}* }
(B) { w#x | w is a substring of x, where w, x ∈ {a, b}* }
(C) { x#w | w^R is a substring of x, where w, x ∈ {a, b}* }
(D) { w#x | w, x ∈ {a, b}* }


Answer: (A)

Explanation: { w#x | w^R is a substring of x, where w, x ∈ {a, b}* }
The following grammar generates language L, where S is the start variable.

S → AT 
A → aAa | bAb | #T 
T → aT | bT | λ  

The strings in the language have the form w#uw^Rv, where u and v are strings of the form (a + b)* (any string made from symbols a and b). The variable T generates the strings u and v, while variable A generates the string w#uw^R and the variable S generates the desired string w#uw^Rv.

Option (A) is correct.

Quiz of this Question


Last Updated : 03 Jan, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads