Module-2 Context Free Grammer and Push Down Autometa.pptx
18. Let G be the grammar S -> 0B | 1A, A -> 0 | 0S | 1AA, B ->1 | 1S | 0BB.
For the string 00110101, find (a) the leftmost derivation, (b) the rightmost derivation, and (c) the derivation tree.
00110101
22. If G is the grammar S SbS | a, show that G is ambiguous.
30. Build the reduced Context-free Grammar without null productions equivalent to the following grammar:
S→ABAC
A→aA | ϵ
B→aB | ϵ
C→c
32. Build the simplified Context-free Grammars equivalent to the given grammars.
(i) SAB
Aa | B
Bb | C
CaC
Db
(ii) S0A0 | 1B1 | BB
AC
BA
Cε
43. 1. (i) Do left factoring for the following grammar:
S AS | AbS | A | a
A aB | aBS | a
B bA | b
(ii) Do left factoring for the following grammar:
A aAB | aA | a
B bB | b
44. (ii) Do left factoring for the following grammar:
A aAB | aA | a
B bB | b
51. Find a grammar in Chomsky normal form equivalent to S aAbB, A aA | a. B bB | b.
54. Reduce the following grammar G to CNF. G is S aAD, A aB I bAB, B b. D d.
57. Find a grammar in GNF equivalent to the grammar
E E + T | T,
T T * F | F
F (E) | a
68. DefInition 7.1 A pushdown automaton consists of
(i) a finite nonempty set of states denoted by Q,
(ii) a finite nonempty set of input symbols denoted by :,
(iii) a finite nonempty set of pushdown symbols denoted by r,
(iv) a special state called the initial state denoted by qo,
(v) a special pushdown symbol called the initial symbol on the
pushdown store denoted by Zo.
(vi) a set of final states, a subset of Q denoted by F, and
(vii) a transition function δ from Q × ( u {A}) x r to the
set of finite subsets of Q × r*.
Symbolically. a pda is a 7-mple, namely (Q, , r, δ, qo, Zo, F).
90. Convert the following Push Down Automata to Context Free Grammar
M = ({q0,q1},{a,b}{z0,za},δ,q0,z0,φ) where δ is given by
δ(q0,a,z0) =(q0, zaz0)
δ(q0,a, za) =(q0,zaza)
δ(q0,b, za) =(q1,Є)
δ(q1,b, za) =(q1,Є)
δ(q1, Є, z0) =(q1,Є)
94. Construct CFG for the PDA M=({q0,q1},{0,1},{R,Z0},δ, q0,Z0,φ) where δ is given
by
δ(q0,1,Z0)={(q0,RZ0)}
δ(q0,1,R)={(q0,RR)}
δ(q0,0,R)={(q1,R)}
δ(q1,0,Z0)={(q0,Z0)}
δ(q0,ε,Z0)={(q0,ε)}
δ(q1,1,R)={(q1,ε)}
97. Construct CFG for the PDA M=({q0,q1},{0,1},{R,Z0},δ, q0,Z0,φ) where δ is given
by
δ(q0,1,Z0)={(q0,RZ0)}
δ(q0,1,R)={(q0,RR)}
δ(q0,0,R)={(q1,R)}
δ(q1,0,Z0)={(q0,Z0)}
δ(q0,ε,Z0)={(q0,ε)}
δ(q1,1,R)={(q1,ε)}