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?

image.pngimage.png

Answer: A. rear nodeFor 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…

  1. A.

    rear node

  2. B.

    front node

  3. C.

    not possible with single pointer

  4. D.

    node next to front

Attempted by 969 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).

Explore the full course: Bpsc

Loading lesson…