GATE | GATE CS 2020 | Question 34
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
Last Updated :
01 Sep, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...