Crack
GATE
C
G
Topic
Stacks
Programming and Data Structures
0
/ 3 done
Questions per paper
All
MCQ
MSQ
NAT
2015 to 2026. Point at a year to read it.
0
1
2015
2019
2021
2023
2025
2026
Show as a table
Year
All
MCQ
MSQ
NAT
2015
0
0
0
0
2018
0
0
0
0
2019
0
0
0
0
2020
0
0
0
0
2021
0
0
0
0
2022
0
0
0
0
2023
1
0
0
1
2024
0.5
0
0.5
0
2025
0
0
0
0
2026
0.5
0
0.5
0
1
CS 2026 Set 2 · 2 marks · MSQ · Moderate
Consider a stack
S
S
S
and a queue
Q
Q
Q
. Both of them are initially empty and have the capacity to store ten elements each. The elements
1
,
2
,
3
,
4
1, 2, 3, 4
1
,
2
,
3
,
4
, and
5
5
5
arrive one by one, in that order. When an element arrives, it is assigned either to
S
S
S
(pushed on
S
S
S
) or to
Q
Q
Q
(enqueued to
Q
Q
Q
). Once all the five elements are stored, the output is generated in two steps. First, stack S is emptied by popping all elements. Then queue
Q
Q
Q
is emptied by dequeueing all elements. The output obtained by following this process is
4
3
1
2
5
4\ 3\ 1\ 2\ 5
4
3
1
2
5
.
2
CS 2024 Set 2 · 2 marks · MSQ · Moderate
Let
S
1
S1
S
1
and
S
2
S2
S
2
be two stacks.
S
1
S1
S
1
has capacity of 4 elements.
S
2
S2
S
2
has capacity of 2 elements.
S
1
S1
S
1
already has 4 elements: 100, 200, 300, and 400, whereas
S
2
S2
S
2
is empty, as shown below.
3
CS 2023 · 2 marks · NAT · Moderate
Consider a sequence
a
a
a
of elements
a
0
=
1
a_0 = 1
a
0
=
1
,
a
1
=
5
a_1 = 5
a
1
=
5
,
a
2
=
7
a_2 = 7
a
2
=
7
,
a
3
=
8
a_3 = 8
a
3
=
8
,
a
4
=
9
a_4 = 9
a
4
=
9
, and
a
5
=
2
a_5 = 2
a
5
=
2
. The following operations are performed on a stack
S
S
S
and a queue
Q
Q
Q
, both of which are initially empty.