Contents
Circular queues
The core idea of a circular queue is that the pointer of the tail should directly point to the head.
Initialising a circular queue
Both head and tail pointing to None
Inserting first element
- Set head as the element
- Set tail as the element
- Set element.next (pointing to) the head of the queue
- (Optional) Increment the size of queue
Adding (Inserting) more elements
Principle: Inserting the element in between the head and the tail. If append, then set new node as the tail, otherwise set new node as head.
Deleting an element
If delete head or tail, remember to update them accordingly.