Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider the grammar shown below.S → C ... Start Learning for Free
Consider the grammar shown below.
S → C C
C → c C | d
The grammar is
  • a)
    LL(1)
  • b)
    SLR(1) but not LL(1)
  • c)
    LALR(1) but not SLR(1)
  • d)
    LR(1) but not LALR(1)
Correct answer is option 'A'. Can you explain this answer?
Verified Answer
Consider the grammar shown below.S → C CC → c C | dThe gra...
Since there is no conflict, the grammar is LL(1). We can construct a predictive parse table with no conflicts. This grammar also LR(0), SLR(1), CLR(1) and LALR(1).
View all questions of this test
Most Upvoted Answer
Consider the grammar shown below.S → C CC → c C | dThe gra...
Context-Free Grammar:
A context-free grammar (CFG) is a set of production rules that define the structure of strings in a formal language. It consists of a set of non-terminal symbols, a set of terminal symbols, a start symbol, and a set of production rules.

LL(1) Grammar:
An LL(1) grammar is a context-free grammar that can be parsed using a top-down parser with a single token lookahead. The LL(1) property means that for any pair of distinct productions for a non-terminal symbol, there must be a unique terminal symbol that can be used to differentiate between them.

SLR(1) Grammar:
An SLR(1) grammar is a context-free grammar that can be parsed using a bottom-up parser called the SLR(1) parser. The SLR(1) property means that for any state in the parser, there must be a unique lookahead symbol that can be used to determine the next action.

LALR(1) Grammar:
An LALR(1) grammar is a context-free grammar that can be parsed using an LALR(1) parser. LALR(1) parsers are a type of bottom-up parser that are more powerful than SLR(1) parsers. LALR(1) grammars can handle a larger class of context-free languages than SLR(1) grammars.

LR(1) Grammar:
An LR(1) grammar is a context-free grammar that can be parsed using an LR(1) parser. LR(1) parsers are a type of bottom-up parser that are more powerful than LALR(1) parsers. LR(1) grammars can handle a larger class of context-free languages than LALR(1) grammars.

Analysis of the Given Grammar:
Let's analyze the given grammar to determine its properties:

S → C CC | c C | d

- The start symbol is 'S'.
- The non-terminal symbols are 'S', 'C', and 'CC'.
- The terminal symbols are 'c' and 'd'.
- The production rules are:
1. S → C CC
2. S → c C
3. S → d

LL(1) Analysis:
To determine if the grammar is LL(1), we need to check if there is a unique terminal symbol for each pair of distinct productions for a non-terminal symbol.

- For the non-terminal symbol 'S', we have three distinct productions.
- S → C CC
- S → c C
- S → d
There is no unique terminal symbol that can be used to differentiate between these productions, as 'C' and 'c' can both be the first symbol.

Therefore, the grammar is not LL(1).

SLR(1) Analysis:
To determine if the grammar is SLR(1), we need to check if there is a unique lookahead symbol for each state in the parser.

- We can construct the SLR(1) parsing table for the grammar, but it may not be feasible to explain it in detail here.
- However, we can observe that the grammar has reduce-reduce conflicts, which means that there are states in the parser where
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Question Description
Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer?.
Solutions for Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer?, a detailed solution for Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? has been provided alongside types of Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the grammar shown below.S → C CC → c C | dThe grammar isa)LL(1)b)SLR(1) but not LL(1)c)LALR(1) but not SLR(1)d)LR(1) but not LALR(1)Correct answer is option 'A'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev