/* */ Click to Join Live Class with Shankar sir Call 9798158723

Data Structure MCQ - Queues


Q1.Following is C like pseudo code of a function that takes a Queue as an argument, and uses a stack S to do processing.
void fun(Queue *Q)
{
    Stack S;  // Say it creates an empty stack S
 
    // Run while Q is not empty
    while (!isEmpty(Q))
    {
        // deQueue an item from Q and push the dequeued item to S
        push(&S, deQueue(Q));
    }
 
    // Run while Stack S is not empty
    while (!isEmpty(&S))
    {
      // Pop an item from S and enqueue the popped item to Q
      enQueue(Q, pop(&S));
    }
}
What does the above function do in general?
  1. Removes the last from Q
  2. Keeps the Q same as it was before the call
  3. Makes Q empty
  4. Reverses the Q

Answer:- (D).
Explanations :The function takes a queue Q as an argument. It dequeues all items of Q and pushes them to a stack S. Then pops all items of S and enqueues the items back to Q. Since stack is LIFO order, all items of queue are reversed.
Q2.Which one of the following is an application of Queue Data Structure?
  1. When a resource is shared among multiple consumers
  2. When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes
  3. Load Balancing
  4. All of the above

Answer:- (D).
Q3.How many queues are needed to implement a stack. Consider the situation where no other data structure like arrays, linked list is available to you.
  1. 1
  2. 2
  3. 3
  4. 4

Answer:- (B).
Explanations :A stack can be implemented using two queues.
Q4.Which of the following is true about linked list implementation of queue?
  1. In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end.
  2. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning.
  3. Both of the above
  4. None of the above

Answer:- (C).
Explanations :To keep the First In First Out order, a queue can be implemented using linked list in any of the given two ways.
Q5.A queue follows __________
  1. FIFO (First In First Out)
  2. LIFO (Last In First Out)
  3. Ordered array
  4. Linear tree

Answer:- (A).
Explanations :Element first added in queue will be deleted first which is FIFO principle.
Q6.Circular Queue is also called ________
  1. Square Buffer
  2. Ring Buffer
  3. Rectangle Buffer
  4. Curve Buffer

Answer:- (B).
Explanations :Circular Queue is also called as Ring Buffer. Circular Queue is a linear data structure in which last position is connected back to the first position to make a circle. It forms a ring structure.
Q7.Which of the following is not the type of queue?
  1. Ordinary queue
  2. Single ended queue
  3. Circular queue
  4. Priority queue

Answer:- (B).
Q8.Suppose 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?
  1. A queue cannot be implemented using this stack.
  2. A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes a sequence of two instructions.
  3. A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction.
  4. A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction each.

Answer:- (C).
Explanations :To DEQUEUE an item, simply POP. To ENQUEUE an item, we can do following 3 operations 1) REVERSE 2) PUSH 3) REVERSE.
Q9. If the elements "A", "B", "C" and "D" are placed in a queue and are deleted one at a time, in what order will they be removed?
  1. ABCD
  2. DCBA
  3. DCAB
  4. ABCD

Answer:- (A).
Explanations :Because Queue follow FIFO rule.
Q10.If the MAX_SIZE is the size of the array used in the implementation of circular queue. How is rear manipulated while inserting an element in the queue?
  1. rear=(rear%1)+MAX_SIZE
  2. rear=rear%(MAX_SIZE+1)
  3. rear=(rear+1)%MAX_SIZE
  4. rear=rear+(1%MAX_SIZE)

Answer:- (C).