...

/

Queue Implementation Using Doubly Linked List

Queue Implementation Using Doubly Linked List

Learn how to implement a queue by using a doubly linked list in this lesson.

A double-ended queue or a deque (sometimes pronounced ā€œdeckā€) is an abstract data type in which elements can be added to or removed from both ends. Letā€™s look at the linked list implementation of the deque.

Queue struct

First of all, letā€™s define a struct for our deque using a doubly linked list.

Press + to interact
type Node struct {
value int
next *Node
prev *Node
}
type Deque struct {
head *Node
tail *Node
size int
}

Queue operations

Now, letā€™s make some common queue operations by using the ...