What is Queue?
Lesson 2 of 12 in Coddy's Queue - Data Structures Series #2 course.
A queue is like a line of people waiting for something.
In programming, a queue is a list of items where you can only add new items to the back of the list, and you can only remove items from the front of the list. It's first in, first out (FIFO) data structure, which means that the item that was added first will be the first one to be removed.
Just like a line of people, you can't jump to the front of the line, you have to wait for your turn. Similarly, in a queue data structure, you have to wait for your turn to get processed.
The five main operations in a queue are:
- Enqueue: Adding an element to the back of the queue.
- Dequeue: Removing the element from the front of the queue.
- Front: Retrieving the first element in the queue without removing it.
- Rear: Retrieving the last element in the queue without removing it.
- Size: Getting the number of elements currently in the queue.
Let's create a Queue class!
Try it yourself
This lesson doesn't include a code challenge.