Queue and deque
Queues are, exactly as the name states, queues of elements. A linked list is addressed by two pointers-one for the top element and one for the tail element. By nature, queues are a FIFO (First In First Out) arrangement of data, meaning that the element that was pushed first is to be popped first, too. It is totally up to you to decide where the queue starts and where it ends-whether top is the beginning or the end of a queue, and the same for tail. Should we want to convert the example of a linked list we used in this chapter to a queue, we would only need to add a list_tail pointer.
Deques are double-ended queues, which means that elements may be pushed into the queue either at the top element or at the tail element depending ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access