group-icon
Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
270 Members
Join this group to post and comment.
Archana Priyadarshini
Archana Priyadarshini
Computer Science
05 Feb 2019

Differences between stack and queue

Stack follows LIFO mechanism on the other hand Queue follows FIFO mechanism to add and remove elements.

In a stack, the same end is used to insert and delete the elements. On the contrary, two different ends are used in the queue to insert and delete the elements.

As Stack have only one open end that is the reason for using only one pointer to refer to the top of the stack. But queue uses two pointers to refer front and the rear end of the queue.

Stack performs two operations known as push and pop while in Queue its known as enqueue and dequeue.

Stack implementation is easier whereas Queue implementation is tricky.

Queue has variants like circular queue, priority queue, doubly ended queue, etc. In contrast, stack does not have variants.