• Tutorials
  • Courses
  • Tracks

GATE | CS | 2018 | Data Structures | Linked List | Question 11

Last Updated :
Discuss
Comments

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 n 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.

Queue


Which one of the following is the time complexity of the most time-efficient implementation of 'enqueue' and 'dequeue, respectively, for this data structure?

Θ(1), Θ(1)

Θ(1), Θ(n)

Θ(n), Θ(1)

Θ(n), Θ(n)

Share your thoughts in the comments