Differences between stack and queue data structure


Stack and queue both are data structure to store data in particular order.

Stack is linear data structure in which objects are inserted or removed at the same end. Therefore, it is visualized as vertical collection. That is the reason why stack is called Last-in-First-out (LIFO) type of list.

Queue is also a linear data  structure in which objects are inserted and removed from two different ends.Queue used two pointers to read and write data from both ends. It is a horizontal collection.

Sr. No.KeyStackQueue

1

Basic 

Stack is linear data structure in which objects are inserted or removed at the same end

Queue is also a linear data  structure in which objects are inserted and removed from two different ends

2

LIFO/FIFO

It is LIFO collections

It is FIFO collection 

3

Pointers

It has only one pointer 

Queue used two pointers to read and write data from both ends

4.

      Operations 

Push and Pop are the operations 

Queue operations are enqueue and dequeue 


Updated on: 21-Jan-2020

346 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements