Which of the following derivation does a top-down parser use while parsing a…

2020

Which of the following derivation does a top-down parser use while parsing a input string? The input is assumed to be scanned in left to right order.

  1. A.

    Topmost derivation

  2. B.

    Leftmost derivation traced out in reverse

  3. C.

    Leftmost derivation

  4. D.

    Rightmost derivation

Attempted by 102 students.

Show answer & explanation

Correct answer: C

The correct option is C (Leftmost derivation).

A top-down parser constructs the parse tree from the root (start symbol) down to the leaves (input tokens). When scanning the input string from left to right, it always expands the leftmost non-terminal symbol first at each step. This process corresponds exactly to finding a Leftmost Derivation (LMD) for the input string.

Explore the full course: Niacl Ao It Specialist