FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

PROGRAMMING LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Grammar that produce more than one Parse tree for same sentence is ____
A
Complementation
B
Precedence
C
Ambiguous
D
Unambiguous
Explanation: 

Detailed explanation-1: -The correct answer is option 2. Concept: A grammar that produces more than one parse tree for some sentence is said to be ambiguous.

Detailed explanation-2: -We can prove this grammar is ambiguous by demonstrating two parse trees for the same terminal string. While in general it may be difficult to prove a grammar is ambiguous, the demonstration of two distinct parse trees for the same terminal string is sufficient proof that a grammar is ambiguous.

Detailed explanation-3: -A grammar is ambiguous if it has more than one leftmost derivations for a sentence. That’s equivalent to saying that it had more than one rightmost derivation for the same sentence because the is a one-to-one correspondence between leftmost and rightmost derivations.

Detailed explanation-4: -A Context Free Grammar is called ambiguous grammar if it produces more than one parse tree (derivation tree) or when more than one left most derivation or right most derivation for the same sentence or input.

Detailed explanation-5: -A single sentence can have multiple parse trees, meaning that its structure in ambiguous. We say the CFG is ambiguous. There are techniques for transforming a grammar to remove certain kinds of ambiguities.

There is 1 question to complete.