It means that the insertion and deletion operations are performed at one end i.e at Top.įollowing table shows the Position of Top which indicates the status of stack: This operation is performed using a Pop() function. Delete operation is based on LIFO principle. New element is added at top of the stack and removed from top of the stack, as shown in the diagram below:Īn element is removed from top of the stack.
![stack definition stack definition](https://pediaa.com/wp-content/uploads/2019/05/Difference-Between-Stack-and-Linked-List-Comparison-Summary.jpg)
Insertion operation can be performed using Push() function. In a stack, inserting and deleting of elements are performed at a single position which is known as, Top. The above diagram represents a stack insertion operation.
![stack definition stack definition](https://miro.medium.com/max/2800/1*hlMABmD_hJmMJlu433KIAg.png)
Push() function is used to add or insert new elements into the stack.Ģ. There are two basic operations performed in a Stack:ġ. “Stack is a collection of similar data items in which both insertion and deletion operations are performed based on LIFO principle”. In a stack, when an element is added, it goes to the top of the stack.Stack is a LIFO (Last In First Out) structure.It is a linear list where all insertions and deletions are permitted only at one end of the list.Stack is an ordered list of the same type of elements.