MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

THEORY OF COMPUTATION

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What data structure can be used with postfix expressions?
A
Queue
B
Hash Table
C
Vector
D
Stack
Explanation: 

Detailed explanation-1: -Detailed Solution. Stack data structure is suitable for evaluating postfix expression.

Detailed explanation-2: -Infix notation in Expression Parsing The normal form of expression that we generally use is the infix notation.

Detailed explanation-3: -Evaluation of postfix expression If it is a digit then, push it on to the stack. If it is an operator then, pop out the top most two contents from the stack and apply the operator on them. Later on, push the result on to stack. If the input symbol is ‘’, empty the stack.

Detailed explanation-4: -Evaluation rule of a Postfix Expression states: While reading the expression from left to right, push the element in the stack if it is an operand. Pop the two operands from the stack, if the element is an operator and then evaluate it. Push back the result of the evaluation. Repeat it till the end of the expression.

Detailed explanation-5: -In postfix notation, the operator appears after the operands, i.e., the operator between operands is taken out & is attached after operands. Example1 − Translate a ∗ d − (b + c) into Postfix form. Solution. ad ∗ bc + − Example2 − Convert a + (b ∗⊝ c) is in Postfix form.

There is 1 question to complete.