NPTEL Compiler Design Week 6 Assignment Answers 2025

NPTEL Compiler Design Week 6 Assignment Answers 2025

1. For the grammar
S’ → S
S → CC
C→ cC | d
In state 0 of LR(1) parser, an item included is

a) C→ .cC; c
b) C→ .cC; d
c) C→ .cC; c,d
d) C → .cC; c, S

Answer :- For Answers Click Here 

2. For the grammar
S’ → S
S → CC
C → cC | d
In state 0 of LR(1) parser, an item included is

a) C→ d; c
b) C→ .d; d
c) C→ .d; c,d
d) C → .d; c, $

Answer :- 

3. In SLR parsing to get a shift-reduce conflict for state I on terminal symbol ‘a’,

a) A →a.ß with First(ß) containing ‘a’ should be in I
b) A →S. be in I with Follow(A) having ‘a’
c) A →aß with First(ß) containing ‘a’ should be in 1 and A →8. be in I with Follow(A) having ‘a’
d) None of the other options

Answer :- 

4. n state I we have the items A →a. and B →S., First(A), Follow(A) and Follow(B ontains the symbol ‘a’. This leads to

a) Shift-reduce conflict
b) Reduce – reduce conflict
c) Both shift-reduce and reduce -reduce conflicts
d) No conflicts

Answer :- 

5. Which of the following statements is true regarding LR parsers?

a) SLR and Canonical LR have the same number of states.
b) LALR and Canonical LR have the same number of states.
c) SLR and LALR have the same number of states.
d) All three have the same number of states.

Answer :- 

6. Construction of parsing table in which strategies do not need the Follow set?

a) SLR and canonical LF
b) Canonical LR and LALR
c) SLR and LALR
d) None of the given options

Answer :- 

7. In SLR parsing for the grammar
E’ → E
E → aEbE | bEaE | e
n state 0, for inputs ‘a’ and ‘b’

a) Both will have shift-reduce conflict
b) Only ‘a’ will have shift-reduce conflict
c) Only ‘b’ will have shift-reduce conflict
d) Neither of the other options

Answer :- For Answers Click Here 

8. Amount of look ahead in LALR parser is

a) 1
b) 2
c) 3
d) None

Answer :- 

9.

Answer :- 

10. Which of the following parser types is the most powerful in terms of recognizing a broader class of grammars?

a) LL(1)
b) SLR(1)
c) LALR(1)
d) LR (1)

Answer :- 

11. What is the similarity between LR, LALR and SLR

a) Use same algorithm, but different parsing table.
b) Same parsing table, but different algorithn
c) Their Parsing tables and algorithm are similar but uses top down approac
d) Both Parsing tables and algorithm are different.

Answer :- For Answers Click Here 
Scroll to Top