GATE | GATE-CS-2005 | Question 59

Consider the grammar

E → E + n | E × n | n 

For a sentence n + n × n, the handles in the right-sentential form of the reduction are
(A) n, E + n and E + n × n
(B) n, E + n and E + E × n
(C) n, n + n and n + n × n
(D) n, E + n and E × n


Answer: (D)

Explanation:

E → E + n       {Applying E → E + n } 
  → E + E * n   {Applying E → E * n } 
  → E + n * n   {Applying E → n } 
  → n + n * n   {Applying E → n } 


Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.