Which data structure is needed to convert infix notation to postfix notation?
Options
- A. Stack
- B. Queue
- C. Branch
- D. Tree
A. Stack
To convert Infix notation (e.g., A + B) to Postfix notation (e.g., A B +), we use a Stack.
Why?
Operators are temporarily stored in a stack.
Stack helps manage:
Operator precedence
Parentheses handling
It follows LIFO (Last In, First Out), which is perfect for this conversion process.
This method is commonly known as the Shunting Yard Algorithm (uses stack internally).
(d) Queue → Used in BFS, not for infix-postfix conversion
(c) Branch → Not a data structure
(a) Tree → Expression trees exist, but direct conversion algorithm uses a stack
Attempt Quiz Now:
BPSC Tre 4.0 DSA Practice Set