……………………….

Dark Mode

5,271 views

6 votes

Consider the following sequence of operations on an empty stack.$$\textsf{push}(54);\textsf{push}(52);\textsf{pop}();\textsf{push}(55);\textsf{push}(62);\textsf{s}=\textsf{pop}();$$Consider the following sequence of operations on an empty queue.$$\textsf{enqueue}(21);\textsf{enqueue}(24);\textsf{dequeue}();\textsf{enqueue}(28);\textsf{enqueue}(32);\textsf{q}=\textsf{dequeue}();$$ The value of $\textsf{s+q}$ is ___________.

10 votes

Best answer

**Stack:**

- Push $54,$ push $52,$ pop (remove top element of stack)
- Now stack $54$ (remove 52), push $55,$ push $62,$ pop
- Now top element is $62$ (remove $62$ as $S$)
- $S=62$

**Queue**

- Enqueue $21,$ Enqueue $24$ dequeue (remove first element of queue)
- Now queue $24$ (remove $21$), Enqueue $28,$ Enqueue $32,$ dequeue
- Starting element is $24$ (remove $24$ as $Q$)
- $Q = 24$

$S+Q = 62+24 = 86$