MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

THEORY OF COMPUTATION

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A given grammar is called ambiguous if
A
two or more productions have the same non-terminal on the left hand side
B
a derivation tree has more than one associated sentence
C
there is a sentence with more than one derivation tree corresponding to it
D
brackets are not present in the grammar
Explanation: 

Detailed explanation-1: -A grammar is said to be ambiguous if there exists more than one leftmost derivation or more than one rightmost derivation or more than one parse tree for the given input string. If the grammar is not ambiguous, then it is called unambiguous. If the grammar has ambiguity, then it is not good for compiler construction.

Detailed explanation-2: -A grammar is said to be ambiguous if there exists more than one left most derivation or more than one right most derivation or more than one parse tree for a given input string. If the grammar is not ambiguous then we call it unambiguous grammar.

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: -Ambiguous grammar: A Context-free grammar is said to be ambiguous if there exists more than one derivation tree for the given input string i.e., more than one LeftMost Derivation Tree (LMDT) or RightMost Derivation Tree (RMDT).

Detailed explanation-5: -Definition. A grammar is ambiguous if there exists a sequence of token that can be derived by two different leftmost derivations. An obvious question is whether there is a better, unambiguous, grammar for simple expressions.

There is 1 question to complete.