| Stack |
|---|
| - Stack is a data structure that stores data objects or items on top of each other. - The last item to go inside the stack is placed at the top of the stack and is accessed first. - To access the item below the top of the stack, the topmost item has to be removed before the item below it can be accessed. - Thus, the stack follows the convention LIFO i.e Last In First Out. Operations supported by stack - Stack supports push, pop and top operations. - Push ( item ) : Adds an item on top of the stack - Pop ( ) : Removes an item at top of the stack. - Top ( ) / Peek ( ) : Returns a copy of an item on top of the stack. Applications of stack – To evaluate an infix expession. – An executable manages the storage required by its functions using a stack. Each time a function gets called, the stack grows. Each time a function returns the stack shrinks. |
© 2019-2026 Algotree.org | All rights reserved.
This content is provided for educational purposes. Feel free to learn, practice, and share knowledge.
For questions or contributions, visit algotree.org
"Talk is cheap. Show me the code. - Linus Torvalds"