Stack
A stack is a conceptual structure consisting of a set of homogeneous elements and is based on the principle of last in first out (LIFO). It is a commonly used abstract data type with two major operations, namely push and pop. Push and pop are carried out on the topmost element, which is the item most recently added to the stack.
The push operation adds an element to the stack The pop operation removes an element from the top position. The
stack concept is used in programming and memory organization in computers.
A stack represents a sequence of objects or elements in a linear data structure format. The stack consists of a bounded bottom and all the operations are carried out on the top position. Whenever an element is added to the stack by the push operation, the top value is incremented by one. When an element is popped out from the stack, the top value is decremented by one. A pointer to the top position of the stack is also known as the stack pointer.
STACK Representation:
Basic features of Stack:
Stack is an ordered list of similar data type. Stack is a LIFO(Last in First out) structure or we can say FILO(First in Last out). push() function is used to insert new elements into the Stack.
pop() function is used to remove an element from the stack. Both insertion and removal are allowed at only one end of Stack called Top. Stack is said to be in Overflow state when it is completely full and is said to be in Underflow state if it is completely empty.
Applications of Stack:
The simplest application of a stack is to reverse a word. You push a given word to stack - letter by letter - and then pop letters from the stack. There are other uses also like: Parsing Expression Conversion(Infix to Postfix, Postfix to Prefix etc.)
Polish notations:
The way to write arithmetic expression is known as a notation. An arithmetic expression can be written in three different but equivalent notations, These notations are −
Infix Notation
Prefix (Polish) Notation
Postfix (Reverse-Polish) Notation
Our Official Website : Web Conquerors (https://www.webconquerors.com/)
Comments
Post a Comment