It follows a technique that is LIFE . LIFO - Last In First Out .
What is stack ?
Assume we have stack of plates or stack of chairs . How does it work?
The top of the plate is called top . Keeping a plate above another plate is called push .
If we want to delete a plate we will first delete the top plate . It is called pop out .
Let's take a example with some integer value
Push - 10
10 - Top
Push - 20
20 - Top
10
Push - 30
30 - Top
20
10
If we want to pop
30 will pop out
20 - Top
10
Again pop
20 is pop
10
Again pop
Null
Top comments (0)