Posts

Showing posts from July, 2021

Stack data collection

Image
STACK  DATA  STRUCTURE IN C++ All That You Need To Know About Stack In C++. Stack is a fundamental data structure which is used to store elements in a linear fashion. Stack follows  LIFO (last in, first out)  order or approach in which the operations are performed. This means that the element which was added last to the stack the will be the first element to be removed from  stack. STACK IN C++ A stack is similar to real-life stack or a pile of things that we stack one above the other. As shown above, there is a pile of plates stacked on top of each other. If we want to add another item to it, then we add it at the top of the stack as shown in the above figure (left-hand side). This operation of adding an item to stack is called “ Push ”. On the right side, we have shown an opposite operation i.e. we remove an item from the stack. This is also done from the same end i.e. the top of the stack. This operation is called “ Pop ”. As shown in the above figure, we see that push and pop are c