recategorized by
26,537 views
54 54 votes

Consider a grammar with the following productions

  • $S  \rightarrow  a \alpha  b \mid b \alpha  c \mid aB$
  • $S  \rightarrow \alpha  S\mid b$
  • $S  \rightarrow \alpha b b\mid ab$
  • $S  \alpha \rightarrow bd b\mid b$

The above grammar is:

  1. Context free
  2. Regular
  3. Context sensitive
  4. $LR(k)$

6 Answers

Best answer
74 74 votes
  • $S\alpha \to$

This violates the condition of context-free grammar that the $\text{LHS}$ must be a single non-terminal symbol. 

  •  $S\alpha \to b$

This violates even the weaker requirement for CSG that the length of $\text{RHS}$ of a production must be at least same as that of $\text{LHS}$. So, the grammar is not even context-sensitive.

Ref: https://stackoverflow.com/questions/8236422/context-free-grammars-versus-context-sensitive-grammars

edited by
5 5 votes

S ∝→ [violates context free]
Because LHS must be single non-terminal symbol.
S ∝→ b [violates CSG]
→ Length of RHS production must be atleast same as that of LHS.


Extra information is added to the state by redefining items to include a terminal symbol as second component in this type of grammar.
Ex: [A → αβa]

A → αβa is a production, a is a terminal (or) right end marker $, such an object is called LR(k).
So, answer is (D) i.e., LR(k).

1 1 vote
According To Chomsky Hierarchy

For CFG L.H.S side should be Single variable,production form is like

S->A where S belongs to Variable and A belongs to Variable and Terminal.(L.H.S sholud be single variable).In Production 4 condition violate.

In Case Of Regular Grammer Same thing follow and some additional also,but L.H.S their should be Single Variable.

In Case Of Context Sensitive

Lets X->Y then

|X|<=|Y|( length of x should be less than or equal to Y).this condition is violate in Production 4 where |Sa|>|b|.

option left only D
1 1 vote
this is an unrestricted grammer and for grammer being LR(K)  it must be first cfg which it is not therefore no option is the answer for this question the question is wrong
1 1 vote

We been given that 

S(alpha) -> b

 This can't be context free as context free language doesn't have a terminal on LHS.(thats why its called context free means free from context around LHS but here in context with S we are also having 'alpha' so can't be context free).Now lets come to context sensative ,this also can't be the case as we know that for context sensative we must have length of RHS >= length of LHS but here RHS has just one element 'b' and LHS has 2 elements S and alpha so this cant be the case.

 

If its not context free then foresure its not regular.

 

THUS (d)

0 0 votes
first three op[tion are because of Sa-->

but why D is correct??

So option d say garramer is LR(k) means there is not SR and RR conflict check LR(1) DFA
Answer:
Position:
Show:

Related questions

40 40 votes
4 answers 4 answers
13.8k
13.8k views
Kathleen asked Oct 8, 2014
13,762 views
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar$S \rightarrow xxW \;\text{{print“1...
27 27 votes
5 5 answers
10.9k
10.9k views
Kathleen asked Oct 8, 2014
10,941 views
Translate the arithmetic expression $a^\ast -(b+c)$ into syntax tree.A grammar is said to have cycles if it is the case that $A \overset{+}{\Rightarrow} A$ Show that no g...
50 50 votes
1 answers 1 answer
20.7k
20.7k views
Kathleen asked Oct 8, 2014
20,692 views
A linker is given object modules for a set of programs that were compiled separately. What information need not be included in an object module?Object codeRelocation bits...
9 9 votes
4 answers 4 answers
5.2k
5.2k views
Kathleen asked Oct 8, 2014
5,211 views
Construct the $\text{LL(1)}$ table for the following grammar.$Expr \rightarrow \_Expr$$Expr \rightarrow (Expr)$$Expr \rightarrow Var\; ExprTail$$ExprTail \rightarrow \_Ex...