634 B
634 B
stack.h
A Stack is a Last-in First-out (or First-in Last-out) data structure used in a variety of algorithms. It is a Dynamic Array that can only add or remove its elements at the end of the buffer, in this case, it represents the top of the stack.
Stack Implementation
It has three main functions: push which adds an element at the top of the stack; pop which removes the top element from the stack; and top which returns the top element without removing it (it is also sometimes called peek).
A Stack is used in algorithms like backtracking, depth-first search, expression evaluation, syntax parsing and many more.