Stacks and Queues

Time Complexity

Enqueue : What would be the time for inserting an element into a queue? Time is constant O(1). Dequeue : Similar to insertion, deletion takes contant time O(1) too. Search : How much time would it take to search for a particular element inside a queue? Searching for a particular element would mean traversing the entire queue in the worst case, so search operation takes linear time O(n).