Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE CS 2020 | Question 34

  • Last Updated : 19 Jul, 2021

Consider the following grammar.

S → aSB ∣ d
B → b 

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is ________ .

Note – This question was Numerical Type.
(A) 6
(B) 7
(C) 8
(D) 4


Answer: (B)

Explanation: According to Bottom Up or Shift Reduce Parsers:

Initially: aaadbbb

1. aaaSbbb  {S→d}
2. aaaSBbb  {B→b}
3. aaSbb  {S→aSB}
4. aaSBb  {B→b}
5. aSb  {S→aSB}
6. aSB  {B→b}
7. S  {S→aSB} 

Therefore, total 7 steps required.



Option (B) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :