Stack-based software architecture
Introduction / Definition
Stack-based architecture organizes execution around last-in-first-out state. Function calls use a call stack containing frames for parameters, locals, and return information. Stack machines also use stacks for intermediate values. Interpreters and virtual machines can use this model.
Syntax / Structure / Formula
call → push frame → execute → pop frame
Detailed Explanation
Nested calls create nested frames. A recursive function creates a frame for each active recursive level.
Example
Example: factorial(5) creates nested calls until the base case.
Output / Result
Frames are removed as calls return.
Important Points / Notes
- Deep recursion can cause stack overflow.
- Stack discipline is LIFO.
Mini Practice Question
What can an activation record contain?