Introduction
Design and Implementation based questions are increasingly becoming common in technical interviews. So here we are back again with a question based on the design and functioning of two kinds of data structures called Queue and Deque and what the difference is between them.
Queue
A Queue is a linear data structure that performs operations in a First In, First Out (FIFO) fashion. It is a container adapter in which elements are inserted at one end of the container and removed from the other.
To use Queue in C++ Standard Template Library, we can use #include<queue> header.
Functions of Queue
The common queue operations are:
- queue<T> () :creates a new empty queue. It returns an empty queue and does take the data type T as parameter input.
- empty(): Returns true if the queue is empty else return 0.
- size(): Returns the size of the queue.
- push(X): push() function adds the element ‘X’ at the end of the queue.
- pop(): pop() function removes the element from the beginning of the queue and decrements its size by 1.

Source: Wikipedia
Time Complexity Analysis
queue() : O(1)
empty() : O(1)
size(): O(1)
push(): O(1)
pop(): O(1)
Read More - Time Complexity of Sorting Algorithms
Note: You can refer to all operations and problems related to Queue and Stack on Coding Ninjas Studio.