Queue vs Dequeue in java [closed]

Deque is short for "double ended queue". With an ordinary queue, you add things to one end and take them from the other. With a double ended queue, you can add things to either end, and take them from either end. That makes it a bit more versatile; for example, you could use it as a stack if you wanted to.

In terms of efficiency, it really depends on the implementation. But generally speaking, you wouldn't expect a deque to outperform a queue, because a (single ended) queue could be implemented in a way that doesn't allow objects to be added or removed at the "wrong" end. Whereas any implementation of a deque would also work as an implementation of a queue.


Deque and queue are abstract data types that can be implemented in different ways. To talk about performance you have to specify which implementations you want to compare and which operation(s) you're interested in. Even better, do the benchmark yourself with the workload your application has and in the environment you're going to use (hardware, operating system, JVM version).

Since every deque is also a queue, in general you can say that deques can be at most as good as a queues.