Skip to content
GATEiit

GATE CSE 2017 Session 2 Q23: Circular queue as singly linked list with FRONT and REAR pointers

Syllabus topic: Arrays, stacks, queues and linked lists

Question

A circular queue has been implemented using a singly linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. Which of the following statements is/are CORRECT for such a circular queue, so that insertion and deletion operations can be performed in O(1) time?

I. Next pointer of front node points to the rear node. II. Next pointer of rear node points to the front node.

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 1/3 mark in GATE.
Show answer and explanation

Answer: B (official GATE 2017 final answer key)

Concept used: In a circular singly linked queue the list runs front to rear and the rear node links back to the front, so both ends are reachable in constant time.

Concept notes

Loading notes…

First step: Trace how a node is inserted at REAR and removed at FRONT, and see which next pointer each operation needs.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Arrays, stacks, queues and linked lists

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key