Difference between Stack and Queue
Stack
Operation Principle — Stacks are based on Last In First Out (LIFO) principle i.e the element inserted at the last, is the first element to come out of the list.
Insertion & Deletion — Insertion and deletion in stacks takes place only from one end of the list referred the top.
Reference Pointer — A stack requires only one reference pointer, referred to as top pointer which always points to the last element present in the list.
Flags — In stacks only one flag is maintained to access the list which always points to the last element present in the list.
Operations — In stack operations are referred to as PUSH and POP. Push operation is adding operation in the stack whereas POP operation is removing an element in the stack.
Extensions — A stack cannot be divided into sub sections and it does not have extensions.
Nature — A stack data structure is not necessarily an ordered collection of data items.
Insertion Of An Element — The most and least accessible elements are referred to as TOP and BOTTOM of the stack.
Checking If A Stack Is Empty — To check if a stack is empty, the following condition is used: TOP==-1.