What is the time complexity of evaluation of postfix expression algorithm?
a) O (N)
b) O (N log N)
c) O (N2)
d) O (M log N)
Explanation: The time complexity of evaluation of infix, prefix and postfix expressions is O (N).
Which of these operators have the highest order of precedence?
a) ‘(‘ and ‘)’
b) ‘*’ and ‘/’
c) ‘~’ and ‘^’
d) ‘+’ and ‘-‘
Explanation: The highest order of precedence is ~ and ^ followed by ‘*’ ,’ /’, ‘+’ ,’-‘ and then braces ‘(‘ ‘)’.
Which of the following is not an application of stack?
a) evaluation of postfix expression
b) conversion of infix to postfix expression
c) balancing symbols
d) line at ticket counter
Explanation: Line at ticket counter is an application of queue whereas conversion of infix to postfix expression, balancing symbols, line at ticket counter are stack applications.
While evaluating a postfix expression, when an operator is encountered, what is the correct operation to be performed?
a) push it directly on to the stack
b) pop 2 operands, evaluate them and push the result on to the stack
c) pop the entire stack
d) ignore the operator
Explanation: When an operator is encountered, the first two operands are popped from the stack, they are evaluated and the result is pushed into the stack.
Which of the following statement is incorrect?
a) Postfix operators use value to their right
b) Postfix operators use value to their left
c) Prefix operators use value to their right
d) In postfix expression, operands are followed by operators
Explanation: All prefix operators use values to their right and all postfix operators use values to their left.
What is the result of the given postfix expression? abc*+ where a=1, b=2, c=3.
a) 4
b) 5
c) 6
d) 7
Explanation: The infix expression is a+b*c. Evaluating it, we get 1+2*3=7.