arrow
arrow
arrow
Any string of terminals that can be generated by the following context free grammar (where S is start nonterminal symbol) S → XY X → 0X|1X|0
Question



Any string of terminals that can be generated by the following context free grammar (where S is start nonterminal symbol)
S → XY
X → 0X|1X|0
Y → Y0|Y1|0

A.

has at least one 1

B.

should end with 0

C.

has no consecutive 0’s or 1’s

D.

has at least two 0’s

Correct option is D


We are tasked with analyzing the strings generated by the given Context-Free Grammar (CFG):
Grammar Rules:
1. S → XY
2. X → 0X|1X|0
3. Y → Y0|Y1|0
Grammar Analysis
· The production S → XY combines strings generated by X and Y.
· X → 0X | 1X | 0: This generates any string ending in 0, e.g., 0, 01, 10, 010, etc.
· Y → Y0 | Y1 | 0: This generates strings starting with 0 and can end with multiple 0s or 1s.
Information Booster:
Option (a): "Has at least one 1"
· Strings like 000 can be generated (no 1 present).
· Hence, this is false.
Option (b): "Has no consecutive 0's or 1's"
· Strings like 00 can be generated, which has consecutive 0s.
· Hence, this is false.
Option (c): "Should end with 0"
· The grammar allows strings like 1 (not ending with 0).
· Hence, this is false.
Option (d): "Has at least two 0's"
· The production rules ensure there will always be at least two 0s in any valid string.
· Hence, this is true.

test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
176k+ students have already unlocked exclusive benefits with Test Prime!

Free Tests

Free
Must Attempt

UGC NET Paper-I (21 August 2024 Shift 2)

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper-I (21 August 2024 Shift 2)

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper-I (21 August 2024 Shift 2)

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English