Intermediate Theory of Computation
Q74 / 100

How would you construct a context-free grammar for the language {aⁱbʲ | i ≠ j}?

Correct! Well done.

Incorrect.

The correct answer is B) A grammar built from the union of {aⁱbʲ | i > j} and {aⁱbʲ | i < j}, each generated using a "matching core" plus extra unmatched symbols on one side

B

Correct Answer

A grammar built from the union of {aⁱbʲ | i > j} and {aⁱbʲ | i < j}, each generated using a "matching core" plus extra unmatched symbols on one side

Explanation

Because {aⁱbʲ | i ≠ j} is the union of "more a's than b's" and "more b's than a's," a CFG generates a balanced aⁿbⁿ core and then prepends extra a's or appends extra b's, illustrating how CFLs are built from simpler component languages.

Progress
74/100