Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

GATE | GATE-CS-2015 (Set 3) | Question 41

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Consider the following grammar G.

  S → F ⎪ H
  F → p ⎪ c
  H → d ⎪ c 

Where S, F and H are non-terminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct?

S1: LL(1) can parse all strings that are generated using grammar G.
S2: LR(1) can parse all strings that are generated using grammar G. 

(A) Only S1
(B) Only S2
(C) Both S1 and S2
(D) Neither S1 and S2


Answer: (D)

Explanation: The given grammar is ambiguous as there are two possible leftmost derivations for string “c”.


First Leftmost Derivation
  S → F 
  F → c

Second Leftmost Derivation
  S → H
  H → c  

An Ambiguous grammar can neither be LL(1) nor LR(1)



Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 07 Sep, 2021
Like Article
Save Article
Similar Reads