← Quiz: CFG and PDA: all 10 questions
Quiz: CFG and PDA · Question 1 of 10
Which grammar generates {a^n b^n | n ≥ 0}?
Which grammar generates {a^n b^n | n ≥ 0}?
- A.S → aS | bS | ε
- B.S → aSb | ε
- C.S → ab | ba
- D.S → aSa | b
Answer & explanation
Correct answer: S → aSb | ε
Each step adds one a on the left and one b on the right.
Can you get the rest right without peeking?
Take the timed Quiz: CFG and PDA quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →