Consider the following grammar: \(π‘†β†’π‘‹π‘Œ \\ π‘‹β†’π‘Œπ‘Žπ‘Œβˆ£π‘Ž \ \ and \ \…

2019

Consider the following grammar:

\(π‘†β†’π‘‹π‘Œ \\ π‘‹β†’π‘Œπ‘Žπ‘Œβˆ£π‘ŽΒ \ \ andΒ \ \ π‘Œβ†’π‘π‘π‘‹\)

Which of the following statements is/are true about the above grammar?​​​​​​

(a) Strings produced by the grammar can have consecutive threeΒ \(π‘Žβ€™s\).

(b) Every string produced by the grammar have alternateΒ \(a\)Β andΒ \(b\).

(c) Every string produced by the grammar have at least twoΒ \(π‘Žβ€™s\).

(d) Every string produced by the grammar haveΒ \(𝑏’s\) in multiple ofΒ 2.

Answer: D. (c) and (d) Only β€” Answer: Every string produced by the grammar has at least two a's and has a number of b's that is a multiple of 2. Reasoning (b's are in multiples of 2): The…

  1. A.

    (a) Only

  2. B.

    (b) and (c) Only

  3. C.

    (d) Only

  4. D.

    (c) and (d) Only

Attempted by 86 students.

Show answer & explanation

Correct answer: D

Answer: Every string produced by the grammar has at least two a's and has a number of b's that is a multiple of 2.

Reasoning (b's are in multiples of 2):

  • The production for Y is Y β†’ bbX, so each time a Y expands it contributes exactly two b's followed by whatever X produces.

  • X can be a (which contributes zero b's) or X β†’ Y a Y, which uses two Y's; since each Y contributes an even number (two plus the b's from an X), the total number of b's contributed by X is always even.

  • Thus every derivation produces an even number of b's, i.e. b's occur in multiples of 2.

Reasoning (at least two a's):

  • Start symbol is S β†’ X Y. Any terminal string from X must contain at least one a because X can reduce directly to a, and any other expansion of X (X β†’ Y a Y) explicitly contains an a.

  • The Y in S expands to bbX, which introduces another X that again must yield at least one a.

  • Therefore every complete string from S contains at least two occurrences of a.

Why the other statements are false:

  • Three consecutive a's cannot appear because any a coming from a Y expansion is separated from other terminals by the "bb" that Y produces; there is no production that places two X-derived a's adjacent without intervening b's.

  • Strings do not have strictly alternating a and b because Y introduces "bb", so there are consecutive b's in typical strings (for example: a b b a).

A video solution is available for this question β€” log in and enroll to watch it.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…