Difference between stack and queue?
Akshay Amin
Select an image from your device to upload
Key difference between Stack and Queue is how elements are added and removed.
Stack
Queue
A Stack follows LIFO (Last In First Out), where the last inserted element is removed first. A Queue follows FIFO (First In First Out), where the first inserted element is removed first. Stack operations are Push and Pop, while Queue operations are Enqueue and Dequeue.
Stack : Stack is works on Last in First out (LIFO) principle . Means elements are add and remove only one way .
Queue : Queue is works on First out First out (FIFO) principle . Which means elements are add first into queue is also remove first .