Learn CS Visual

How Stacks Work

A stack always retrieves the value that was added most recently — an order called LIFO, last in, first out. push adds a value to the top, and pop removes the value from the top. A function call stack works on this exact same mechanism.

After pushing 1, 2, and 3 in order, calling pop once, what value comes out?