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 PYQ2014Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider a hash table with 99 slots. The hash function is h(k)=kmod  9h(k)= k \mod 9. The collisions are resolved by chaining. The following 99 keys are inserted in the order: 5,28,19,15,20,33,12,17,105, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain lengths in the hash table, respectively, are
Official PYQ2014Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Suppose a stack implementation supports an instruction REVERSE\text{REVERSE}, which reverses the order of elements on the stack, in addition to the PUSH\text{PUSH} and POP\text{POP} instructions. Which one of the following statements is TRUE\text{TRUE} (with respect to this modified stack)?
Official PYQ2014Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider the C function given below. Assume that the array listAlistA contains n(>0)n (>0) elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j, k; i = 0; j = n-1; do { k = (i+j)/2; if (x <= listA[k]) j = k-1; if (listA[k] <= x) i = k+1; } while (i <= j); if (listA[k] == x) return(k); else return -1; } Which …
Official PYQ2014Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider a hash table with 100100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 33 slots are unfilled after the first 33 insertions?
Official PYQ2013Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
The procedure given below is required to find and replace certain characters inside an input character string supplied in array AA. The characters to be replaced are supplied in array oldcoldc, while their respective replacement characters are supplied in array newcnewc. Array AA has a fixed length of five characters, while arrays oldcoldc and newcnewc …
Official PYQ2013Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
The procedure given below is required to find and replace certain characters inside an input character string supplied in array AA. The characters to be replaced are supplied in array oldcoldc, while their respective replacement characters are supplied in array newcnewc. Array AA has a fixed length of five characters, while arrays oldcoldc and newcnewc …
Official PYQ2013Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider the following operation along with Enqueue and Dequeue operations on queues, where kk is a global parameter. MultiDequeue(Q){ m = k while (Q is not empty) and (m > 0) { Dequeue(Q) m = m – 1 } } What is the worst case time complexity of a sequence of nn queue operations on an initially empty queue?
Official PYQ2012Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Suppose a circular queue of capacity (n−1)(n −1) elements is implemented with an array of nn elements. Assume that the insertion and deletion operations are carried out using REAR\textsf{REAR} and FRONT\textsf{FRONT} as array index variables, respectively. Initially, REAR=FRONT=0\textsf{REAR} = \textsf{FRONT} = 0. The conditions to detect queue full and queue empty …
Official PYQ2010Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
A hash table of length 1010 uses open addressing with hash function h(k)=k mod   10h(k) = k \: \mod \: 10, and linear probing. After inserting 66 values into an empty hash table, the table is shown as below …
Official PYQ2010Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
A hash table of length 1010 uses open addressing with hash function h(k)=kmod  10h(k) = k \mod 10, and linear probing. After inserting 66 values into an empty hash table, the table is shown as below …
Official PYQ2009Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
The keys 12,18,13,2,3,23,512, 18, 13, 2, 3, 23, 5 and 1515 are inserted into an initially empty hash table of length 1010 using open addressing with hash function h(k)=kmod  10h(k) = k \mod 10 and linear probing. What is the resultant hash table?
Official PYQ2007Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Consider a hash table of size seven, with starting index zero, and a hash function (3x+4)mod  7(3x + 4)\mod 7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1,3,8,101, 3, 8, 10 is inserted into the table using closed hashing? Note that − denotes an empty location in the table.
Official PYQ2006Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
An implementation of a queue QQ, using two stacks S1S1 and S2S2, is given below: void insert (Q, x) { push (S1, x); } void delete (Q) { if (stack-empty(S2)) then if (stack-empty(S1)) then { print(“Q is empty”); return; } else while (!(stack-empty(S1))){ x=pop(S1); push(S2,x); } x=pop(S2); } Let nn insert and m(≤n)m(\leq n) delete operations be …
Official PYQ2005Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
A program PP reads in 500500 integers in the range [0,100][0, 100] representing the scores of 500500 students. It then prints the frequency of each score above 5050. What would be the best way for PP to store the frequencies?
Official PYQ2004Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Given the following input (4322,1334,1471,9679,1989,6171,6173,4199)(4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function xx mod 1010, which of the following statements are true? 9679,1989,41999679, 1989, 4199 hash to the same value 1471,61711471, 6171 hash to the same value All elements hash to the same value Each element hashes to a different value
Official PYQ2004Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
The best data structure to check whether an arithmetic expression has balanced parentheses is a
Official PYQ2004Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
A single array A[1…MAXSIZE]A[1 \ldots \text{MAXSIZE}] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1top1 and top2top2 (top1<top2)(top1 < top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full”\text{“}\textsf{stack full}\text{”} is
Official PYQ2003Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Let S be a stack of size n≥1n \geq1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform nn pop operations. Assume that Push and Pop operations take XX seconds each, and YY seconds elapse between the end of one such stack operation and the start of the next operation. For m≥1m \geq1, define the …
Official PYQ2001Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
What is the minimum number of stacks of size nn required to implement a queue of size nn?
Official PYQ2000Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
An n×nn \times n array vv is defined as follows: v[i,j]=i−jv\left[i,j\right] = i - j for all i,j,i≤n,1≤j≤ni, j, i \leq n, 1 \leq j \leq n The sum of the elements of the array vv is