The GATE Grind

GATE Programming and Data Structures: Stacks and Queues – Previous Year Questions

9 GATE previous year questions on Stacks and Queues (Programming and Data Structures, Computer Science) with answers and explanations, from every paper.

  1. GATE 2016 CS Q20 (1 mark, Multiple choice) – A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is…
  2. GATE 2016 CS Q51 (2 marks, Numerical answer) – Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it…
  3. GATE 2018 CS Q13 (1 mark, Multiple choice) – A 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. Let n denote…
  4. GATE 2026 CS (CS2) Q50 (2 marks, Multiple select) – Consider a stack S and a queue Q, both initially empty and each capable of storing ten elements. The elements 1, 2, 3, 4, and 5 arrive one by one in…
  5. GATE 2025 CS (CS2) Q45 (2 marks, Multiple select) – Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and…
  6. GATE 2024 CS (CS2) Q48 (2 marks, Multiple select) – Let S1 and S2 be two stacks. S1 has capacity 4 and already holds 100, 200, 300, 400 (400 on top). S2 has capacity 2 and is empty. Operations: PushToS2…
  7. GATE 2023 CS Q59 (2 marks, Numerical answer) – Consider a sequence a of elements a 0 = 1, a 1 = 5, a 2 = 7, a 3 = 8, a 4 = 9, and a 5 = 2. The following operations are performed on a stack S and a…
  8. GATE 2022 CS Q62 (2 marks, Numerical answer) – Consider the queues Q 1 containing four elements (1, 2, 3, 4 with 1 at the head) and Q 2 containing none (shown as the Initial State in the figure).…
  9. GATE 2021 CS Q31 (1 mark, Numerical answer) – Consider the following sequence of operations on an empty stack. push(54); push(52); pop(); push(55); push(62); s = pop(); Consider the following…