GATE CSE 2018 Q13: Queue on a singly linked list: enqueue at head, dequeue at tail
- Programming and Data Structures
- 1 mark
- MCQ
- −1/3 if wrong
Syllabus topic: Arrays, stacks, queues and linked lists
Question
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let denote the number of nodes in the queue. Let enqueue be implemented by inserting a new node at the head, and dequeue be implemented by deletion of a node from the tail.

Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: B (official GATE 2018 final answer key)
Concept used: In a singly linked list, inserting at the front is constant time, but deleting the last node requires its predecessor, which can only be found by traversal.
First step: Ask, for each operation, which node’s next pointer must be changed and whether that node can be reached directly from head or tail.
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
Source: official GATE 2018 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Programming and Data Structures PYQs
- 2026 Session 1 · Q23Non-leaf indices in a 1-indexed binary heap with n odd
- 2026 Session 1 · Q24Empty slots after linear-probing inserts with h(x) = (x+7) mod 11
- 2026 Session 1 · Q33Maximum height of a full binary tree with 23 nodes
- 2026 Session 1 · Q34Output of a C function with a shadowed block variable
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked list
- 2026 Session 1 · Q40Third insertion that can never yield a complete BST of 1..15