Queue¶
Definition¶
Unlike a Stack, a Queue is a data structure that inserts elements at the tail (enqueue) and accesses/removes elements at the head (dequeue).
Motivation¶
Sequential
Limited access
First-In First-Out (FIFO) access
- When might I actually use this?
- Building a task manager
- Modeling traffic patterns
- Printing a document (or several documents) in proper order
Attributes¶
- head
- is_empty
- size
Operations¶
- enqueue()
- dequeue()
- clear()