Stack


Use this little tool to understand it clearer...

Go ahead, enter some number in input box and hit push, then try pop and see what happens..


This kind of data structure is very helpful for various kind of applications, for example in path searching algorithm, whenever you find a good node to select, you push it into the stack, now at end when you reach goal node, you want to know the path you followed, for this you'll pop out element one by one that'll make your path, this process is called back tracking.