The GATE Grind

GATE 2017 CS (CS2) – Question 23

Programming and Data Structures · Linked Lists · 1 mark · Multiple choice

A circular queue uses a singly linked list, with value and next-pointer per node and exactly two external pointers FRONT and REAR. For O(1) insertion and deletion, which is correct? I: FRONT.next points to REAR. II: REAR.next points to FRONT.

  1. I only
  2. II only
  3. Both
  4. Neither

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) II only

Explanation

Rear.next must point to the front to complete the circular chain. Enqueue inserts after rear and updates rear; dequeue removes front and updates rear.next, each in constant time. Front.next normally points to the second node, not rear. Only II, B.

More Linked Lists questions

All Linked Lists questions →