22/03/2025
** Stacks and Queues **
In C++, stacks and queues are data structures for storing data in specific orders.
Stacks are designed to operate in a Last-In-First-Out context (LIFO), where elements are inserted and extracted only from one end of the container.
push() add an element at the top of the stack.pop() remove the element at the top of the stack.
Queues are designed to operate in a First-In-First-Out context (FIFO), where elements are inserted into one end of the container and extracted from the other.
push() add an element at the end of the queue.pop() remove the element at the front of the queue.
int main()
{
std::stack tower;
tower.push(3);
tower.push(2);
tower.push(1);
while(!tower.empty()) {
std::cout