Consider a sequence of elements , and . The following operations are performed on a stack S and a queue Q, both of which are initially empty.
I: push the elements of a from a0 to a5 in that order into S.
II: enqueue the elements of a from a0 to a5 in that order into Q.
III: pop an element from S.
IV: dequeue an element from Q.
V: pop an element from S.
VI: dequeue an element from Q.
VII: dequeue an element from Q and push the same element into S.
VIII: Repeat operation VII three times.
IX: pop an element from S.
X: pop an element from S
The top element of S after executing the above operations is ________.
GATE CS 2023 (Forenoon) — Question 59
Data StructuresAbstract Data Types (ADTs), Stacks, QueuesNAT2 marksMedium
A GATE question every morning
One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.
More on Abstract Data Types (ADTs), Stacks, Queues
- GATE CS 2026 (Afternoon) · Q50Consider a stack S and a queue Q . Both of them are initially empty and have the capacity to store ten elements each. The elements 1, 2, 3,…
- GATE CS 2025 (Afternoon) · Q45Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer…
- GATE CS 2024 (Afternoon) · Q48Let S1 and S2 be two stacks. S1 has capacity of 4 elements. S2 has capacity of 2 elements. S1 already has 4 elements: 100, 200, 300, and 40…
- GATE CS 2022 (Forenoon) · Q62Consider the queues Q 1 containing four elements and Q 2 containing none (shown as the Initial State in the figure). The only operations al…
- GATE CS 2021 (Forenoon) · Q31Consider the following sequence of operations on an empty stack. push (54); push (52); pop ( ); push (55); push (62); s = pop ( ); Consider…
- GATE CS 2018 (Forenoon) · Q13A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Le…

