When we can insert and delete from both ends, why is it called a deque? Also, what are the applications of a deque?
I'm a student studying data structures for the first time. Thanks!
When we can insert and delete from both ends, why is it called a deque? Also, what are the applications of a deque?
I'm a student studying data structures for the first time. Thanks!
It's also known as the double-ended queue. It's called this because it provides a generalized queue which we can modify from both the head or the tail. Hence, double-ended.
When should we use one? Whenever we want fast access to inserts and deletes at both the beginning and the end. Scheduling and modeling real life queues are common examples.
One application I could think of is maintaining a Playlist of songs.
append
) or the "play next" option adds the song to the front of the queue (appendleft
)For real-world application read this answer