Suppose a stack implementation supports, in addition to PUSH and POP, an…
PYQ GATE 2000
Suppose a stack implementation supports, in addition to PUSH and POP, an operation REVERSE, which reverses the order of the elements on the stack. (a) To implement a queue using the above stack implementation, show how to implement ENQUEUE using a single operation and DEQUEUE using a sequence of 3 operations. (b) The following postfix expression, containing single digit operands and arithmetic operators + and *, is evaluated using a stack. 52*34+52**+ Show the contents of the stack. (i) After evaluating 5 2 * 3 4 + (ii) After evaluating 5 2 * 3 4 + 5 2 (iii) At the end of evaluation.
Attempted by 2 students.
Sign up free to check your answer
Sign up freeLoading lesson…

