Parsing Techniques: Top-down and Bottom-up Parsing MCQs

1. What is the main difference between top-down parsing and bottom-up parsing?

A) Top-down parsing starts from the start symbol, while bottom-up parsing starts from the input string.
B) Bottom-up parsing is faster than top-down parsing.
C) Top-down parsing processes the entire string before deriving rules.
D) Bottom-up parsing never uses a stack for intermediate storage.

Answer: A) Top-down parsing starts from the start symbol, while bottom-up parsing starts from the input string.


2. Which of the following is an example of a top-down parsing method?

A) LL Parsing
B) LR Parsing
C) SLR Parsing
D) LALR Parsing

Answer: A) LL Parsing


3. In bottom-up parsing, the parsing process:

A) Works from the start symbol to the input string
B) Derives the start symbol from the input string
C) Continually refines the input string to reach a single start symbol
D) Analyzes the syntax tree directly from top to bottom

Answer: B) Derives the start symbol from the input string


4. Which of the following is NOT a property of top-down parsing?

A) It constructs the parse tree from the root to the leaves.
B) It often uses recursive descent techniques.
C) It can backtrack when an invalid derivation is encountered.
D) It processes the input from the leaves to the root.

Answer: D) It processes the input from the leaves to the root.


5. Which of the following parsing techniques requires no backtracking and uses a single lookahead symbol?

A) LL(1) Parsing
B) LR Parsing
C) Recursive Descent Parsing
D) SLR Parsing

Answer: A) LL(1) Parsing


6. Which parsing technique is generally more efficient for a larger set of grammars?

A) Top-down parsing
B) Bottom-up parsing
C) LL(1) Parsing
D) Recursive Descent Parsing

Answer: B) Bottom-up parsing


7. Which of the following is a disadvantage of top-down parsing?

A) It requires less memory compared to bottom-up parsing.
B) It cannot handle left-recursive grammars easily.
C) It always produces a leftmost derivation.
D) It is faster than bottom-up parsing in all cases.

Answer: B) It cannot handle left-recursive grammars easily.


8. In the context of LL(1) parsing, the “1” refers to:

A) The number of symbols that the parser looks ahead during parsing
B) The number of parsing techniques used
C) The number of non-terminal symbols in the grammar
D) The maximum recursion depth in the grammar

Answer: A) The number of symbols that the parser looks ahead during parsing


9. Which of the following is a characteristic of bottom-up parsing?

A) It starts from the input and constructs the parse tree bottom to top.
B) It uses left recursion only.
C) It is easy to implement using recursive functions.
D) It never requires a lookahead symbol.

Answer: A) It starts from the input and constructs the parse tree bottom to top.


10. Which of the following is true about LR parsing?

A) It is a top-down parsing technique.
B) It uses a stack to store intermediate parsing results.
C) It is more suitable for grammars with left recursion.
D) It does not require lookahead symbols.

Answer: B) It uses a stack to store intermediate parsing results.


11. Which type of grammar can be parsed using top-down parsing methods?

A) Ambiguous grammars
B) Left-recursive grammars
C) LL(1) grammars
D) Non-context-free grammars

Answer: C) LL(1) grammars


12. Which of the following is a key advantage of bottom-up parsing over top-down parsing?

A) Bottom-up parsing requires less memory.
B) Bottom-up parsing is always faster.
C) Bottom-up parsing handles left recursion without modification.
D) Bottom-up parsing requires less lookahead than top-down parsing.

Answer: C) Bottom-up parsing handles left recursion without modification.


13. What is a “shift-reduce” operation used in bottom-up parsing?

A) Shifting involves moving a non-terminal symbol to the stack, while reduce involves applying a production rule.
B) Shift involves pushing input symbols onto a stack, while reduce involves removing a non-terminal symbol and replacing it with a rule.
C) Shift involves replacing a terminal symbol with a non-terminal, while reduce removes the non-terminal.
D) Shift involves replacing the start symbol with terminal symbols only.

Answer: B) Shift involves pushing input symbols onto a stack, while reduce involves removing a non-terminal symbol and replacing it with a rule.


14. Which of the following is an example of a bottom-up parsing technique?

A) Recursive Descent Parsing
B) LL(1) Parsing
C) SLR Parsing
D) Predictive Parsing

Answer: C) SLR Parsing


15. Which of the following statements is true for a recursive descent parser?

A) It is a bottom-up parser
B) It always parses left-recursive grammars
C) It is a top-down parsing technique
D) It can parse grammars with multiple symbols in each production rule

Answer: C) It is a top-down parsing technique

Leave a Reply

Your email address will not be published. Required fields are marked *