Multiple choice

The grammar E $\rightarrow$E + E |E*E|(E)| id is

  1. left recursive

  2. ambiguous

  3. both (1) and (2)

  4. none of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

E$\rightarrow$E + Eand E$\rightarrow$E*E are left recursive. This grammar permits two distinct leftmost derivations for the sentence id + id *idE$\Rightarrow$E + E                      E$\Rightarrow$E*E  $\Rightarrow$id + E                        $\Rightarrow$E + E*E  $\Rightarrow$id + E*E                  $\Rightarrow$id + E*E  $\Rightarrow$id + id*E                  $\Rightarrow$id + id*E  $\Rightarrow$id + id*id                  $\Rightarrow$id + id*ESo it is ambiguous also.