Match the following:
View worked solution
Answer: C
To find the correct match, we analyze each programming language concept and its corresponding formal language representation:
-
E → R (Checking that identifiers are declared before their use):
Checking if an identifier is declared before its use requires matching the exact name of the identifier at two different places in the program. This is modeled by the non-context-free language: where the first represents the declaration, represents the intermediate code, and the second represents the usage. -
F → P (Matching formal and actual parameters):
When matching the number of formal parameters to actual parameters across multiple or nested function calls, we need to maintain multiple independent counts in a cross-serial manner. This is modeled by the non-context-free language: where the count of 's matches 's, and the count of 's matches 's. -
G → Q (Arithmetic expressions with matched parentheses):
The context-free grammar: generates arithmetic expressions where and act as binary operators, acts as an operand, and and act as matching opening and closing parentheses (like(and)). -
H → S (Palindromes):
The grammar: is the standard context-free grammar that generates even-length palindromes over the alphabet .
Thus, the correct matching is E-R, F-P, G-Q, H-S, which corresponds to option C.
Free practice · Your answers on this page are not saved.
