Which of the following operations on a queue data structure has a time complexity of O(1)?
A) Enqueue
B) Dequeue
C) Peek
D) Clear
(A)
A and B
(B)
B only
(C)
C only
(D)
A and D
Answer: (B)
Explanation:
In a queue data structure, dequeueing (removing an element from the front of the queue) typically has a time complexity of O(1) because it involves removing the first element and adjusting the front pointer.
Hence, Option B is the correct option.
Quiz of this Question
Please comment below if you find anything wrong in the above post