Consider a standard circular queue ‘q’ implementation (which has same condition for queue full and queue empty) whose size is 11 and the elements of the queue are q[0], q[1], .... q[10]. The front and rear pointers are initialized to point at q[2]. In which position will the ninth element be added ?
Consider a standard circular queue ‘q’ implementation (which has same condition for queue full and queue empty) whose size is 11 and the elements of the queue are q[0], q[1], .... q[10]. The front and rear pointers are initialized to point at q[2]. In which position will the ninth element be added ? Correct Answer q[0]
The correct answer is “option 1”.
KEY POINTS:
A Queue is a data structure based on the FIFO rule.
Insertion & deletion is done from the REAR & FRONT pointer respectively.
A circular queue is a queue whose last element is connected back to the first element.
Insertion operation in the queue is known as En-queue.
Deletion operation in the queue is known as De-queue.
IMPORTANT point:
The en-queue operation first increments the REAR pointer & then insert the element.
The de-queue operation first increments FRONT and then deletes the element.
EXPLANATION:
.
Therefore, the 9th element will get placed in q.
Hence, the correct answer is “option 1”.