Queue: GATE CS Previous Year Questions

Queue · Data Structures

14 questions · asked in 13 of 27 years (2000–2026)

MCQ 9 · MSQ 1 · NAT 41-mark 7 · 2-mark 7

2000Questions per year2026

Questions 11–14 of 14

Q11GATE 20122 marksMCQ−0.67 if wrong
Suppose a circular queue of capacity (n-1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are

Q12GATE 20071 markMCQ−0.33 if wrong
Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:
i. isEmpty(Q) returns true if the queue is empty, false otherwise.
ii. delete(Q) deletes the element at the front of the queue and returns its value.
iii. insert(Q,i) inserts the integer i at the rear of the queue.
Consider the following function
void f (queue Q) {
int i ;
if (!isEmpty(Q)) {
   i = delete(Q);
   f(Q);
   insert(Q, i);
  }
} 

What operation is performed by the above function f ?

Q13GATE 20061 markMCQ−0.33 if wrong
An implementation of a queue Q, using two stacks S1 and S2, 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 n insert and m(≤\leqn) delete operations be performed in an arbitrary on an empty queue Q, Let x and y be the number of push and pop operations performed respectively in the processes. Which one of the following is true for all m and n ?

Q14GATE 20011 markMCQ−0.33 if wrong
What is the minimum number of stacks of size n required to implement a queue to size n ?

Keep practising

Topics in Data Structures

All CS topics ›