What is the difference between bottom-up and top-down parsing?
15 views
- Bottom-up parsing starts from the top of the parse tree, while top-down parsing starts from the bottom
- Bottom-up parsing starts from the leaves of the parse tree, while top-down parsing starts from the root (Correct Answer)
- Bottom-up parsing constructs the parse tree in a depth-first manner, while top-down parsing constructs it in a breadth-first manner
- There is no difference between bottom-up and top-down parsing
Explanation
Answer: b) Bottom-up parsing starts from the leaves of the parse tree, while top-down parsing starts from the root.
Explanation: Bottom-up parsing starts from the leaves of the parse tree and works its way up to the root, by applying production rules in reverse order until the start symbol is reached. Top-down parsing starts from the root and works its way down to the leaves, by applying production rules in the order specified by the grammar until the sentence is reached.