Skip to content

GATE CS Arrays, Stacks and Queues questions

Practise Arrays, Stacks and Queues questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2026Programming and Data StructuresArrays, Stacks and QueuesMSQ · 2 marks
Consider a stack SS and a queue QQ. Both of them are initially empty and have the capacity to store ten elements each. The elements 1,2,3,41,2,3,4, and 55 arrive one by one, in that order. When an element arrives, it is assigned either to SS (pushed on SS ) or to QQ (enqueued to QQ ). Once all the five elements are stored, the output is …
Official PYQ2025Programming and Data StructuresArrays, Stacks and QueuesMCQ · 2 marks
​A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures: P. Unsorted doubly linked list with pointers to the head node and tail node of the list. Q. Min-heap implemented using an array. R. Binary Search Tree. Which ONE of the following options gives the …
Official PYQ2025Programming and Data StructuresArrays, Stacks and QueuesMCQ · 2 marks
​​​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 that all keys are distinct. We wish to augment the stack data structure with an O(1)O(1) time MIN operation that returns a pointer to the record with smallest key present in the stack without deleting the …
Official PYQ2024Programming and Data StructuresArrays, Stacks and QueuesMSQ · 2 marks
​​​​​Let S1\mathrm{S} 1 and S2\mathrm{S} 2 be two stacks. S1\mathrm{S} 1 has capacity of 44 elements. S2\mathrm{S} 2 has capacity of 22 elements. S1\text{S1} already has 44 elements: 100,200,300100,200,300, and 400400, whereas S2\text{S2} is empty, as shown below. …
Official PYQ2023Programming and Data StructuresArrays, Stacks and QueuesNAT · 2 marks
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 Q,Q, both of which are initially empty. push\textsf{push} the elements of aa from a0a_{0} to a5a_{5} in that order into SS. enqueue\textsf{enqueue} the elements of aa from …
Official PYQ2022Programming and Data StructuresArrays, Stacks and QueuesMCQ · 2 marks
What is printed by the following ANSI C\text{ANSI C} program? #include<stdio.h> int main (int argc, char *argv[]) { int a[3][3][3] = {{1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17, 18}, {19, 20, 21, 22, 23, 24, 25, 26, 27}}; int i = 0, j = 0, k = 0; for ( i = 0; i < 3; i ++) { for ( k = 0; k < 3; k++) printf(“%d”, a[i][j][k]); printf …
Official PYQ2022Programming and Data StructuresArrays, Stacks and QueuesNAT · 2 marks
Consider the queues Q1Q_{1} containing four elements and Q2Q_{2} containing none (shown as the Initial State\textsf{Initial State} in the figure). The only operations allowed on these two queues are Enqueue (Q, element)\textsf{Enqueue (Q, element)} and Dequeue (Q).\textsf{Dequeue (Q)}. The minimum number of Enqueue\textsf{Enqueue} operations on Q1Q_{1} required to place the elements of …
Official PYQ2021Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
​​​​​Let PP be an array containing nn integers. Let tt be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of nn elements. Which one of the following choices is correct?
Official PYQ2021Programming and Data StructuresArrays, Stacks and QueuesNAT · 1 mark
Consider the following sequence of operations on an empty stack.push(54);push(52);pop();push(55);push(62);s=pop();\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. …
Official PYQ2018Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
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 nn denote the number of nodes in the queue. Let 'enqueue' be implemented by inserting a new node at the head, and 'dequeue' be implemented by deletion of a node from the tail. Which one of the following is the time …
Official PYQ2017Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
A circular queue has been implemented using a singly linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. Which of the following statements is/are CORRECT for such a circular queue, so …
Official PYQ2016Programming and Data StructuresArrays, Stacks and QueuesNAT · 1 mark
Let QQ denote a queue containing sixteen numbers and SS be an empty stack. Head(Q)Head(Q) returns the element at the head of the queue QQ without removing it from QQ. Similarly Top(S)Top(S) returns the element at the top of SS without removing it from SS. Consider the algorithm given below. while Q is not Empty do if S is Empty OR Top(S) ≤ Head …
Official PYQ2016Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT (nn refers to the number of items in the queue) ?
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
What is the output of the following C code? Assume that the address of xx is 20002000 (in decimal) and an integer requires four bytes of memory. int main () { unsigned int x [4] [3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}; printf ("%u, %u, %u", x + 3, *(x + 3), *(x + 2) + 3); }
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesNAT · 1 mark
Consider the C program below #include <stdio.h> int *A, stkTop; int stkFunc (int opcode, int val) { static int size=0, stkTop=0; switch (opcode) { case -1: size = val; break; case 0: if (stkTop < size ) A[stkTop++]=val; break; default: if (stkTop) return A[--stkTop]; } return -1; } int main() { int B[20]; A=B; stkTop = -1; stkFunc (-1, 10); stkFunc …
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesNAT · 1 mark
A Young tableau is a 2D2D array of integers increasing from left to right and from top to bottom. Any unfilled entries are marked with ∞\infty, and hence there cannot be any entry to the right of, or below a ∞\infty. The following Young tableau consists of unique entries. …
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider the following two C code segments. YY and XX are one and two dimensional arrays of size nn and n×nn \times n respectively, where 2≤n≤102 \leq n \leq 10. Assume that in both code segments, elements of YY are initialized to 00 and each element X[i][j]X[i][j] of array XX is initialized to i+ji+j. Further assume that when stored in main …
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesNAT · 1 mark
Given that hash table TT with 2525 slots that stores 20002000 elements, the load factor aa for TT is _________.
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
The result evaluating the postfix expression 10 5+60 6/∗8−10 \ 5 + 60 \ 6 / * 8 - is
Official PYQ2015Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider the following C program segment. # include <stdio.h> int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); } What will be printed by the program?