A stack stores items in a last-in, first-out (LIFO)
Picture a pile of dirty plates in your sink. As you add more
plates, you bury the old ones further down. When you take a plate
off the top to wash it, you're taking the last plate you put
in. "Last in, first out."
Fast operations. All stack operations take
The call stack is a stack that tracks function calls in a program. When a function returns, which function do we "pop" back to? The last one that "pushed" a function call.
Depth-first search uses a stack (sometimes the call stack) to keep track of which nodes to visit next.