Unit-III
Unit-III
What is the relationship between nondeterministic pushdown automata (PDA) and context-
free grammars (CFG)? Remembering
Answer: Nondeterministic pushdown automata and context-free grammars are equivalent in their
expressive power. This means that for every context-free language, there exists a corresponding
nondeterministic pushdown automaton that recognizes it, and vice versa.
2. Explain the concept of parse trees in the context of context-free grammars. Understanding
Answer: Parse trees represent the syntactic structure of a sentence according to the production
rules of a context-free grammar. Each node in the tree corresponds to a non-terminal symbol, and
the edges represent the application of production rules. The leaves of the tree correspond to the
terminal symbols of the language.
Answer: Ambiguity refers to the property of a context-free grammar where a single sentence can
have more than one valid parse tree. Ambiguity can lead to different interpretations of the same
input, which may cause issues in parsing and understanding the language.
4. State the pumping lemma for context-free languages and its significance.
Answer: The pumping lemma for context-free languages states that for any context-free language,
there exists a constant pumping length such that any sufficiently long string in the language can be
divided into substrings, which can be pumped (repeated) to generate additional strings in the
language. It serves as a tool to demonstrate the non-context-freeness of certain languages.
Answer: Deterministic pushdown automata always have a unique next move for any given state
and input symbol combination, whereas nondeterministic pushdown automata can have multiple
possible next moves for the same combination. NPDA can recognize a broader class of languages
compared to DPDA.
Answer: Context-free languages are closed under union, concatenation, Kleene star, and reversal
operations. This means that if two languages are context-free, their union, concatenation, Kleene star,
and reversal will also be context-free.
7. What are context-sensitive grammars (CSG), and how do they differ from context-free
grammars (CFG)? Remembering
Answer: Context-sensitive grammars allow for more flexible production rules compared to
context-free grammars. In CSG, the left-hand side of a production rule can be a context-sensitive
string, which includes both terminal and non-terminal symbols. This increased expressive power
allows CSG to generate languages that cannot be described by CFG.
8. Explain the concept of linear bounded automata (LBA) and their equivalence with context-
sensitive grammars (CSG).
Answer: Linear bounded automata are Turing machines whose tape space is linearly bounded by
the size of the input string. They are equivalent in power to context-sensitive grammars, meaning
that for every language recognized by an LBA, there exists a corresponding context-sensitive
grammar, and vice versa.
Answer: Ambiguity in context-free grammars can lead to multiple valid parse trees for a single
input string, causing parsing algorithms to potentially produce different interpretations or fail to
determine the correct syntactic structure of the input.
10. What are some practical applications of context-sensitive languages in computer science?
PART B
1. Write the procedure and Eliminate left recursion from the following Grammar
EE+T/T
TT*F/F
F(E)/id
2. a) Explain about derivation and parse trees? Construct the string 0100110 from the
Leftmost and Rightmost derivation.
S0S/1AA
A0/1A/0B
b) Find the parse tree for generating the string 11001010 from the given grammar.
[L2,5M] S1B/0A
A1/1S/0AA B0/0S/1BB
3. a) Define
Ambiguous grammar.
b) Remove Left recursion from the grammar SSab/T
TTcd/F
FFa/G
4. a) Explain Left
recursion and Left factoring.
b) Perform left factor from the grammar AabB/aB/cdg/cdeB/cdfB
5. Simplify the following context free grammar. (Here, Ʌ stands for epsilon (ϵ)).
STU|V
TaTb|Ʌ
UcU| Ʌ
VaVc|W
WbW| Ʌ
Convert the following grammar into Greibach normal form.
SAA/a
ASS/b
PART C
1. a) Write the process for Convert the grammar into CNF?
b)Convert the following grammar into CNF.
SbA/aB AbAA/aS/a BaBB/bS/a.
2. a) What is linear grammar? Explain in detail with example.
b) Explain the closure properties of context free languages.
3. a)Remove the unit production from the grammar SAB,AE,BC,CD,Db,Ea
b)Remove ϵ productions from the grammar
SABaC, ABC, Bb/ ϵ, CD/ ϵ, Dd
4. a) Write about Decision problems for CFLs with example?
b)What is the differentiate between CFG and Regular Language?