The stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Pop Operation on Stacks: Accessing the content while removing it from the top of the stack, is known as a Pop Operation. In an array implementation of pop() operation, the data element is not actually removed, instead top is decremented to a lower position in the stack to point to the next value. But in linked-list implementation, pop() actually removes data element and deallocates memory space.
Approach: A pop() operation may involve the following steps:
- Check if the stack is empty or not.
- If the stack is empty, produces an error and exit.
- If the stack is not empty, accesses the data element at which top is pointing.
- Delete the element, using array.pop() operation on buffer.
- Return success.
Example 1: This example describes only push operation on stack.
Example 2: This example uses two Pop operations after pushing the element in the stack by calling stack1.pop() function.
- p5.js | Push Operation on Stack
- p5.js | Enqueue Operation in Queue
- p5.js | Dequeue Operation in Queue
- How to perform click-and-hold operation inside an element using jQuery ?
- MERN Stack
- PHP | Ds\Stack __construct() Function
- PHP | Ds\Stack capacity() Function
- PHP | Ds\Stack count() Function
- PHP | Ds\Stack allocate() Function
- What is full stack development ?
- Print PHP Call Stack
- PHP | Ds\Stack Functions Complete Reference
- How to choose a Technology Stack for Web Application Development ?
- How to Become a Full Stack Web Developer in 2019 : A Complete Guide
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.