Why do we need Deque data structures in the real world?

user366312 picture user366312 · Oct 7, 2010 · Viewed 34.6k times · Source

Can anyone give me an example of situation where a Deque data structure is needed?

Note - Please don't explain what a deque is?

Answer

shiv.mymail picture shiv.mymail · Feb 23, 2013

A Deque is a double ended queue, allowing inserting and removing from both ends.

In real scenario we can attached it to a Ticket purchasing line, It performs like a queue but some time It happens that some body has purchased the ticket and sudden they come back to ask some thing on front of queue. In this scenario because they have already purchased the ticket so they have privilege to come and ask for any further query. So in these kind of scenario we need a data structure where according to requirement we add data from front. And In same scenario user can also leave the queue from rear.

So it follows completely data structure of Deque.