Questions: Context-Free Grammars

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Language L has two CFGs: Grammar G₁ allows some strings to be derived in multiple ways (ambiguous), while Grammar G₂ derives every string in exactly one way (unambiguous). What can we conclude about L?

AL is not context-free because an ambiguous grammar exists for it
BL is context-free, and the existence of an unambiguous grammar confirms this
CL is inherently ambiguous — the unambiguous G₂ must be incorrect
DG₁ and G₂ generate different languages; the unambiguous one defines the 'true' L
Question 2 Multiple Choice

A student argues that {a^n b^n c^n | n ≥ 0} is context-free because 'a pushdown automaton can count the a's on the stack, match them to b's, and then match the remaining stack contents to c's.' What is the flaw in this reasoning?

APushdown automata cannot use their stack to count symbols
BThe stack can match a's to b's by popping as b's are read, but once the stack is empty at the end of the b's, no memory remains to verify the count of c's
CThe language is regular and therefore too simple to require a context-free grammar
DThe pumping lemma does not apply to languages defined with three distinct symbol types
Question 3 True / False

If a context-free grammar for a language is ambiguous, then the language itself is inherently ambiguous and no unambiguous grammar for it can exist.

TTrue
FFalse
Question 4 True / False

The class of languages generated by context-free grammars is exactly the class of languages recognized by nondeterministic pushdown automata.

TTrue
FFalse
Question 5 Short Answer

Explain why a pushdown automaton can recognize {a^n b^n | n ≥ 0} but cannot recognize {a^n b^n c^n | n ≥ 0}. What property of the stack makes the difference?

Think about your answer, then reveal below.