Would a Queue benefit from being implemented with a doubly linked list instead of a single linked list?


#1

Question

In this exercise, the implementation for the Queue class uses a singly linked list. Is there any benefit from using a doubly linked list?

Answer

For the implementation of a Queue, a singly linked list is sufficient because the insertion and removal of data occur at either end of the queue. There is another type of queue data structure known as a Deque which allows for the insertion and removal to occur from either end of the structure. In this case, the use of a doubly linked list would be beneficial.