Questions & Answers of Queues

Question No. 113

A circular queue has been implemented using a singly linked list where each node consist 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 rear node of the queue, respectively. Which of the following statement is/ are CORRECT for such a circular queue, so that insertion and deletion operations can be performed in 0(1) time?

I. Next pointer of front node point to the rear node.

II. Next pointer of rear node points to the front node.

Question No. 20

A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed ef?ciently. Which one of the following statements is CORRECT (n refers to the number of items in the queue)?

Question No. 51

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 from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.

The maximum possible number of iterations of the while loop in the algorithm is____________ .

Question No. 151

Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?

Question No. 44

Consider the following operation along with Enqueue and Dequeue operations on queues, where k 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 n queue operations on an initially empty queue?

Question No. 35

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