Stack: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Stack is a data structure that | Stack is a data structure that implements a LIFO (last-in first-out) ordering upon which the following operations are supported: | ||
* push(object): add object on the top of the stack O(1) | * push(object): add object on the top of the stack O(1) | ||
* pop(): remove the object which on the top of the stack O(1) | * pop(): remove the object which on the top of the stack O(1) | ||
* peek(): return object which is on the top of the stack O(1) | * peek(): return object which is on the top of the stack O(1) | ||
A stack can be used to implement recursive algorithm iteratively. | A stack can be used to implement recursive algorithm iteratively. | ||
Latest revision as of 04:38, 3 October 2020
Stack is a data structure that implements a LIFO (last-in first-out) ordering upon which the following operations are supported:
- push(object): add object on the top of the stack O(1)
- pop(): remove the object which on the top of the stack O(1)
- peek(): return object which is on the top of the stack O(1)
A stack can be used to implement recursive algorithm iteratively.