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”.

Related Questions

In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into EMPTY queue?
How far is point 'R' from Point 'T'? Statement (I): Point 'R' is 5 metres to the north of point 'M'. Point 'U' is 4 metres to the east of point 'R'. Point 'T' is to the west of point 'R' such that points 'U' 'R' and 'T' form a straight line of  metres. Statement (II): Point 'Z' is metres to the south of point 'T'. Point 'U' is  metres to the east of point 'T'. Point 'M' is  metres to the east of point 'Z'. Point 'R' is  metres to the north of point 'M'. Point 'R' lies on the line formed by joining points 'T' and 'U'.