Comparison
Queue Operations | Array Implementation | Linked-List Implementation | ||
---|---|---|---|---|
Time Complexity | Space Complexity | Time Complexity | Space Complexity | |
Enqueue | O (1) | O (1) | O (1) | O (1) |
Dequeue | O (1) | O (1) | O (1) | O (1) |
IsFull | O (1) | O (1) | O (N) | O (1) |
IsEmpty | O (1) | O (1) | O (1) | O (1) |
Peek | O (1) | O (1) | O (1) | O (1) |
Related articles:
Name some Queue implementations and compare them by efficiency of operations
A queue is a linear data structure in which insertion is done from one end called the rear end and deletion is done from another end called the front end. It follows FIFO (First In First Out) approach. The insertion in the queue is called enqueue operation and deletion in the queue is called dequeue operation.
A queue can be implemented in two ways:
- Array implementation of queue
- Linked List implementation of queue