480 views

3 Answers

Best answer
3 votes
3 votes

Option (A) is correct as for multiple $‘!’$ , The derivation is only possible via $’C’$ which is on the left side of $‘!’$ in the production .So it is left associative.

Option (B) is correct as for multiple $‘*’$ , The derivation is only possible via $’A’$ which is on the right side of $‘*’$ in the production .So it is right associative.

Option (D) is correct as for multiple $‘@’$ , The derivation is only possible via $’B’$ which is on the left side of $‘@’$ in the production .So it is left associative.

Option (C) is wrong as ‘&’  is neither  left nor right associative .

Reference:- GATE CSE 1997 | Question: 1.6 - GATE Overflow for GATE CSE

selected by
1 votes
1 votes

Answer: a, b, d

If the production right recursive like S → A = S then ‘=’ is right associative.

If the production is left recursive like S → S + A then ‘+; is left associative.

Now see in problem

For ‘!’ production is C → C ! D, it is left recursive so operator is left associative.

For ‘*’ production is A → B * A, it is right recursive so operator is right associative.

For ‘&’ production is A → C & C, so we can’t comment about associativity since this production is neither left recursive or right recursive.

For ‘@’ production is B → B @ C, it is left recursive so operator is left associative.

1 votes
1 votes

Left-recursive => Left-associative

Right-recursive => Right-associative

C → C!D : Left-recursive, so ! is left-associative

A → B*A : Right-recursvie, so * is right-associative

B → B@C : Left-recursive, so @ is left-associative

No related questions found