in DS retagged by
5,271 views
6 votes
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 ___________.
in DS retagged by
by
5.3k views

1 comment

……………………….

2
2

3 Answers

10 votes
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$

edited by
0 votes
0 votes

ANS IS 86

JUST SEE BASIC OPERATIONS OF STACK AND QUEUE.

 

edited by
0 votes
0 votes

s = 62 

p = 24

s+p = 62+24  = 86

Answer:

Related questions