arrow
arrow
arrow
The following code: stmt → if expr then stmt else stmt | if expr then stmt suffers from:
Question



The following code:
stmt → if expr then stmt else stmt
| if expr then stmt
suffers from:

A.

Ambiguity

B.

Left factoring

C.

Left Recursion

D.

λ-moves

Correct option is A


The given grammar is ambiguous because a string like ‘if expr then if expr then stmt else stmt’ can have more than one parse tree. This ambiguity makes it unclear whether the else clause is associated with the first or second if statement. Ambiguity in grammars leads to difficulties in parsing and interpreting code correctly, which is why it is critical to resolve or avoid ambiguous grammars in language design.

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow