NAT · 2 marks · Linear Data Structures

GATE CS 2023 CS — Q59

Consider a sequence aa of elements a0=1,a1=5,a2=7,a3=8,a4=9a_0 = 1, a_1 = 5, a_2 = 7, a_3 = 8, a_4 = 9, and a5=2a_5 = 2. The following operations are performed on a stack SS and a queue QQ, both of which are initially empty.

I: push the elements of aa from a0a_0 to a5a_5 in that order into SS.
II: enqueue the elements of aa from a0a_0 to a5a_5 in that order into QQ.
III: pop an element from SS.
IV: dequeue an element from QQ.
V: pop an element from SS.
VI: dequeue an element from QQ.
VII: dequeue an element from QQ and push the same element into SS.
VIII: Repeat operation VII three times.
IX: pop an element from SS.
X: pop an element from SS.

The top element of SS after executing the above operations is ____________.