AI engineering glossary · Data structures algorithms

What is deque?

Deque (also called double-ended queue): A double-ended queue that supports adding and removing items efficiently at both the front and the back. It generalises both a stack and a queue and is handy for sliding-window problems.

Level: intermediateTopic: Data structures algorithms

Deque: an example

Python's collections.deque lets you call append and popleft in constant time, unlike a list where removing from the front shifts every item.

Related terms

More Data structures algorithms terms

Where you learn it

Deque is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.