Machine-translated by Google. Questions are authored in English.
Top

Discussion

Assertion (A): LR grammars are usually written with left recursion for list constructs.
Reason (R): A right recursive list forces the entire list onto the stack before the first reduction can take place.

  • A.Both A and R are true, and R is the correct explanation of A
  • B.Both A and R are true, but R is not the correct explanation of A
  • C.A is true but R is false
  • D.A is false but R is true

Answer: A

Both are true and the reason gives the mechanism, and the difference is measurable on long lists. Left recursion reduces after each element and keeps the stack at constant depth, which matters for generated initialiser lists and similar input.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.