Overview
A queue is a data structure that stores items according to the First In First Out (FIFO) principle. The item that has been in the queue the longest is the first one to be removed.| Operations | Complexity |
|---|---|
| Enqueue (insert end) | O(1) |
| Dequeue (delete first) | O(1) |
| Peek (view first) | O(1) |
Implementation
In a queue, operations occur at both ends, so using an array is not efficient since removing the first element is costly. A linked list implementation is more suitable.Queue