Stack A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into stack is called push operation, and deletion of an element from the stack is called pop operation. In stack we always keep track of the last element present in the list with a pointer called top.

Queue: A queue is a linear data structure in which elements can be inserted only from one side of the list called rear, and the elements can be deleted only from the other side called the front. The queue data structure follows the FIFO (First In First Out) principle, i.e. the element inserted at first in the list, is the first element to be removed from the list. The insertion of an element in a queue is called an enqueue operation and the deletion of an element is called a dequeue operation. In queue we always maintain two pointers, one pointing to the element which was inserted at the first and still present in the list with the front pointer and the second pointer pointing to the element inserted at the last with the rear pointer.

the differances between stack and queue:

FIFO & LILO and LIFO & FILO Principles Queue: First In First Out (FIFO): The first object into a queue is the first object to leave the queue, used by a queue.
Stack: Last In First Out (LIFO): The last object into a stack is the first object to leave the stack, used by a stack
OR
Stack: Last In First Out (FILO): The First object or item in a stack is the last object or item to leave the stack.
Queue: Last In First Out (LILO): The last object or item in a queue is the last object or item to leave the queue.
