A circular linked list is used to represent a queue. A single variable ‘P’ is…
2021
A circular linked list is used to represent a queue. A single variable ‘P’ is used to access the queue. To which node should ‘P’ point so that both enqueue and dequeue operations can be performed in constant time?


Answer: A. rear node — For constant-time operations: Dequeue needs quick access to front Enqueue needs quick access to rear In a circular linked list, if we keep one pointer P at…
- A.
rear node
- B.
front node
- C.
not possible with single pointer
- D.
node next to front
Attempted by 974 students.
Show answer & explanation
Correct answer: A
For constant-time operations: Dequeue needs quick access to front
Enqueue needs quick access to rear
In a circular linked list, if we keep one pointer P at the rear node, then: Front = P → next
Rear = P
So both enqueue (insert after rear) and dequeue (remove front) take O(1).