CT2 Part B Questions
CT2 Part B Questions
3. Remove Left recursion and left factoring for the following grammars
S→Aa/Ab A→Ad/Sc/€
4. Consider the following Grammar
P → PP+ | PP* | b
Give a left most derivation and parse tree for the string bb+b*.
5. Consider the following Grammar
P → PP+ | PP* | b
Give a Right most derivation and parse tree for the string bb+b*.
Group-II
|∈
listTail→; list
|∈
2. For the given grammar S→ 0S1 | 01 , Write a derivation and draw parse tree for the
string w= 0515
R→R-T | T
T→T / F| F
F→ P ^ F | P
P→(R) | a | b
1. Find leading and trailing for all the non-terminals from the following grammar
S→Aa|bAc|Bc|bBa
A→d
B→d
2. Find leading and trailing for all the non-terminals from the following grammar
R→R-T|T
T→T/F|T
F→F*P|P
P→(R)|a|b
3. Find leading and trailing for all the non-terminals from the following grammar
A→B |ApqA
B →qB|q
4. Find leading and trailing for all the non-terminals from the following grammar
P → (Q) | x
Q → Q,P | P
5. Find leading and trailing for all the non-terminals from the following grammar
C →A=L
C →L
A →*L
A→i
L →A
Group-IV
1. Derive a string " (a,a) " using RMD for the following grammar and identify all the
handles for the same.
S→a | ↑ | (T)
T→T,S | S
2. Derive a string " id=*id " using RMD for the following grammar and identify all the
handles for the same.
S→L=R
S→R
L→*R
L→id
R→L
3. Derive a string " abab " using RMD for the following grammar and identify all the
handles for the same.
S →AS | b
A →SA | a
4. Derive a string " dcccd " using RMD for the following grammar and identify all the
handles for the same.
S → CC
C →cC | d
5. Derive a string " xbbcb " using RMD for the following grammar and identify all the
handles for the same.
S→xABC
A→a|bbD
B→a|ε
C→b|ε
D→c|ε
Group-V
1. Parse the input string “ccdd” using shift reduce parsing for the following grammar
S → CC
C →cC | d
2. Parse the input string “(a,a)” using shift reduce parsing for the following grammar
S→a | ↑ | (T)
T→T,S | S
3. Parse the input string “xbbcab” using shift reduce parsing for the following grammar
S→xABC
A→a|bbD
B→a|ε
C→b|ε
D→c
4. Parse the input string “aabbd” using shift reduce parsing for the following grammar
S→aSA|a
A→bB|cc
B→bd|a
5. Parse the input string “ibtaea” using shift reduce parsing for the following grammar
S→iEtS|iEtSeS| a
E→b
Group-VI
1. Check whether the grammar is LL(1) or not by constructing predictive parsing table
E→ idE'
E' → +EE'|*EE'| ∈
2. Check whether the grammar is LL(1) or not by constructing predictive parsing table
S→aSS'
S'→aS'| ∈
3. Check whether the grammar is LL(1) or not by constructing predictive parsing table
A → (A)A' | aA'
A' → AA' | ∈
4. Check whether the grammar is LL(1) or not by constructing predictive parsing table
X→aXX'
X'→aX'| ∈
Group-VII
X→ (Y) | e
Y→Y ,X | X
Parse the input (e,e)
Group-VIII
A→Abc
A→b
A→bAc| bc
S →bSb
S→ a
S →b
S→Ɛ
S→aSb
S→ab
S →aSa
S →bSb
S→c
S →B
S →SabS
B→bB
B→ Ɛ
Group X