From the course: Python Data Structures: Stacks, Deques, and Queues

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Deques: An introduction

Deques: An introduction

- [Instructor] First of all, a deque stands for a double-ended queue, where we take the D, the E, and the first two letters of the queue and put them all together to create this new word called deque. The high-level definition of a deque is that it's an abstract data type that resembles both a stack and a queue. Deques can hold a collection of items and order is sort of preserved in a queue. You'll see soon why I use the phrase sort of. In a queue, you can add both items to the front and to the back, and you can also remove items from the front and the back as well. In the next few videos, we'll be looking at three main operations. Reverse, which allows us to reverse the order of elements in the deque, Rotate, which allows us to rotate the elements in the deque to the right or to the left. And extend, which allows us to extend the deque within other iterable, such as a list. A queue uses a first in first out, or…

Contents