Skip to content
GATEiit

GATE CSE 2023 Q39: Language of S → aSb | X, X → aX | Xb | a | b

Question

Consider the context-free grammar GG below

S→aSb∣XX→aX∣Xb∣a∣b,\begin{aligned} S &\to aSb \mid X \\ X &\to aX \mid Xb \mid a \mid b, \end{aligned}

where SS and XX are non-terminals, and aa and bb are terminal symbols. The starting non-terminal is SS.

Which one of the following statements is CORRECT?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: B (official GATE 2023 final answer key)

Concept used: Find the language of the inner non-terminal first, then see what the outer rule adds.

First step: Show that XX generates exactly a∗(a+b)b∗a^*(a + b)b^*, then check what wrapping it in an…bna^n \ldots b^n does.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2023 CS question paper and final answer key, organised by IIT Kanpur. Question paper · Answer key