Google News
logo
Algorithm - Interview Questions
What are the differences between stack and Queue?
Stack and Queue both are non-primitive data structure used for storing data elements and are based on some real-world equivalent.
 
Let's have a look at key differences based on the following parameters.
 
Working principle : The significant difference between stack and queue is that stack uses LIFO (Last in First Out) method to access and add data elements whereas Queue uses FIFO (First in first out) method to obtain data member.
 
Structure : In Stack, the same end is used to store and delete elements, but in Queue, one end is used for insertion, i.e., rear end and another end is used for deletion of elements.
 
Number of pointers used : Stack uses one pointer whereas Queue uses two pointers (in the simple case).
 
Operations performed : Stack operates as Push and pop while Queue operates as Enqueue and dequeuer.
 
Variants : Stack does not have variants while Queue has variants like a circular queue, Priority queue, doubly ended Queue.
 
Implementation : The stack is simpler while Queue is comparatively complex.
Advertisement