A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer

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

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)

Ans: θ(1), θ(n)

Take Mock Tests

Government Schemes Mock Test Start Test!
Political Science Mock Test – 42 Start Test
History Test – 190 Start Test
Quantitative Aptitude Test Start Test!
Data Interpretation - Mock Test Start Test!
General Awareness - Mock Test Start Test!
Reasoning Ability - Mock Test Start Test!
We will be happy to hear your thoughts

Leave a reply

Gkseries.com
Logo
Register New Account