1

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!

P R
  • 1,293
  • 7
  • 28
  • 58

2 Answers2

0

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.

Eric Hotinger
  • 8,957
  • 5
  • 36
  • 43
0

One application I could think of is maintaining a Playlist of songs.

  • Next song is played from the front of the queue(i.e. playlist).
  • You can add a song to the queue (append) or the "play next" option adds the song to the front of the queue (appendleft)

For real-world application read this answer

Premkumar chalmeti
  • 800
  • 1
  • 8
  • 23