What is Stack?
The stack is a linear data structure like an array in which only the last inserted element can be accessed. This data structure works over the principle Last In First Out (LIFO). It is very fast since it has to access only last added element so it requires constant time to do so having complexity O(1).
Stacks should be used over arrays when we need to work with data in the LIFO form. Push operation on the stack is used to adds an item in the stack. If the stack is full, then it is said to be an Overflow condition.
Basic skeleton of stack: Below example run using “$node skeleton.js” command to get basic stack skelton.
Example: This example describe the push operation on stack.
After Pushing ’14’ by calling stack1.push(14) function to the top of stack.
- p5.js | Pop Operation in Stack
- Node.js | push() function
- How to push a value based on matched value in PHP ?
- PHP | Ds\Sequence push() Function
- PHP | Ds\Vector push() Function
- PHP | Ds\Deque push() Function
- PHP | SplDoublyLinkedList push() Function
- Sending Push Notifications : Progressive Web Apps
- p5.js | Dequeue Operation in Queue
- p5.js | Enqueue Operation in Queue
- How to perform click-and-hold operation inside an element using jQuery ?
- MERN Stack
- What is full stack development ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.