Gate CS-2018 Question Paper With Solutions

Q. 11 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.

Gate CS-2018 Question Paper With Solutions

 

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

(A) Θ(1), Θ(1)

(B) Θ(1), Θ(n)

(C) Θ(n), Θ(1)

(D) Θ(n), Θ(n)

Answer: (B)

Explanation:

Gate CS-2018 Question Paper With Solutions

Learn More:   Gate EC-2010 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here