8,460 views
5 votes
5 votes

Consider a standard Circular Queue implementation (which has the same condition for Queue Full and Queue Empty) whose size is $11$ and the elements of the queue are $q[0], q[1], \ldots q[10]$.

The front and rear pointers are initialized to point at $q[2]$. In which position will the ninth element be added?

  1. $q[0]$
  2. $q[1]$
  3. $q[9]$
  4. $q[10]$

5 Answers

10 votes
10 votes

Answer (A)

In Standard Implementation of Circular Queue,

  • For enqueue, we increment the REAR pointer and then insert an element
  • For dequeue, we increment the FRONT and then remove the element at that position.
  • For empty check, when FRONT == REAR, we declare queue as empty

5 votes
5 votes

in circular queue front =rear queue is empty

(rear+1) mod n == front queue is full

1st element inserted at q[2] 2nd at q[3] and so on so 9th element inserted at q[10]

3 votes
3 votes
in a circular queue if front=rear then the queue is empty, insert first element at q[2] thus the ninth element will go to q[10].
Answer:

Related questions

4 votes
4 votes
5 answers
2
go_editor asked Jul 1, 2016
5,928 views
Consider the following binary search tree T given below: Which node contains the fourth smallest element in T?QVWX
9 votes
9 votes
9 answers
3
ajit asked Sep 23, 2015
14,494 views
How many different trees are there with four nodes $\text{A, B, C}$ and $\text{D}?$$30$$60$$90$$120$
5 votes
5 votes
2 answers
4