COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
While converting infix to postfix expression, what would be pushed into the stack?
|
only operators
|
|
opening symbol ‘(’
|
|
operators and opening symbol
|
|
operands
|
|
operators and operands
|
Explanation:
Detailed explanation-1: -If we have an opening parenthesis “(", we push it into the stack. If we have an operand, we append it to our postfix expression.
Detailed explanation-2: -To convert infix expression to postfix expression, we will use the stack data structure. By scanning the infix expression from left to right, when we will get any operand, simply add them to the postfix form, and for the operator and parenthesis, add them in the stack maintaining the precedence of them.
Detailed explanation-3: -What is the corresponding postfix expression for the given infix expression? Explanation: Using the infix to postfix expression conversion algorithm using stack, the corresponding postfix expression is found to be abcdef^/*g*h*+.
There is 1 question to complete.