Stack vs Queue

Stack and Queue are common data structures that every engineer and developer must understand. The difference is only in its order system. Here are the details.

Stack

The order is First In Last Out (FILO) or Last In First Out (LIFO). Only focus on the one element that is the end of the stack called Top. Adding a new element to the top of the stack is called Push. Removing an element of the top of the stack is called Pop.

Stack
Source: https://en.wikipedia.org/wiki/File:Lifo_stack.png

Queue

The order is First In First Out (FIFO) or Last In Last Out (LILO). Focus on the element of the Front or Head and Back or Tail of the queue. Adding a new element to the end of the queue is called Enqueue. Removing an element from the beginning of the queue is Dequeue.

Queue
Source: https://en.wikipedia.org/wiki/File:Data_Queue.svg