Stack in Computer Science
The stack is a list of elements in which an element may be inserted may be inserted or deleted only at one end. This means that elements are removed from a stack in the reverse order of that in which they are inserted. It is a linear data structure which follows a particular order in which the operations are performed. The stack concept is used in programming and memory organization in computers.
Push and Pop Operation
In computer science, a stack or LIFO (Last In First Out) is an abstract data type that serves as a collection of elements, with two principle operation.
- Push adds an element to the collection. Push operation adds an element to the stack.
- Pop removes the last element that was added. The pop operation removes an element from the top position.
It is a commonly used abstract data type with two major operations, namely, push and pop. The term LIFO stems from the fact that using these operations the first element “Popped Off” a stack it series of pushes and pops is the last element that was pushed in the sequence. This is equivalent to the requirement that considered as a linear data structure, or more abstractly a sequential collection the push and pop operation occur only at one end of the structure referred to as the top of the stack. A helpful analogy is to think of a stack of books; you can remove only the top book, also you can add a new book on the top.