0% found this document useful (0 votes)
6 views

Unit-III

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Unit-III

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

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.

3. What is ambiguity in the context of context-free grammars? Remembering

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.

5. What distinguishes deterministic pushdown automata (DPDA) from nondeterministic


pushdown automata (NPDA)? Remembering

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.

6. Discuss the closure properties of context-free languages (CFLs) Creating

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.

9. How does ambiguity in context-free grammars affect parsing algorithms? Remembering

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?

Answer: Context-sensitive languages find applications in natural language processing, compiler


design, syntax analysis, and formal language theory. They are used to model complex syntactic
structures and behaviors in various computational systems.

PART B
1. Write the procedure and Eliminate left recursion from the following Grammar
EE+T/T
TT*F/F
F(E)/id
2. a) Explain about derivation and parse trees? Construct the string 0100110 from the
Leftmost and Rightmost derivation.
S0S/1AA
A0/1A/0B

b) Find the parse tree for generating the string 11001010 from the given grammar.
[L2,5M] S1B/0A
A1/1S/0AA B0/0S/1BB
3. a) Define
Ambiguous grammar.
b) Remove Left recursion from the grammar SSab/T
TTcd/F
FFa/G

4. a) Explain Left
recursion and Left factoring.
b) Perform left factor from the grammar AabB/aB/cdg/cdeB/cdfB
5. Simplify the following context free grammar. (Here, Ʌ stands for epsilon (ϵ)).
STU|V
TaTb|Ʌ
UcU| Ʌ
VaVc|W
WbW| Ʌ
Convert the following grammar into Greibach normal form.
SAA/a
ASS/b

PART C
1. a) Write the process for Convert the grammar into CNF?
b)Convert the following grammar into CNF.
SbA/aB AbAA/aS/a BaBB/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 SAB,AE,BC,CD,Db,Ea
b)Remove ϵ productions from the grammar
SABaC, ABC, Bb/ ϵ, CD/ ϵ, Dd
4. a) Write about Decision problems for CFLs with example?
b)What is the differentiate between CFG and Regular Language?

You might also like