07-Stacks&Queues - Ch Chapter 7 Stacks and Queues...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Ch t 7 St k d Q Chapter 7: Stacks and Queues This material is based on contents the book: “Data structures, Algorithms, and Software Principles in C”, from T.A. Standish. Parts also under permission from David McCaughan, University of Guelph, Canada. USF – COP4530 – Data Structures Summer 2009 1 of 23
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Recursive functions in C using stacks C uses a run-time stack to call functions A stack frame is a collection of information E h i i i t k Each running program is given a stack Stack is filled up with function calls For every new function call, a new stack frame appears New stacks are put on top of previous stacks Each one will point to previous one USF – COP4530 – Data Structures Summer 2009 2 of 23
Image of page 2
Recursive functions in C using stacks Stack frame for function F contains 1 S t h ld th l V t d b th f ti 1. Space to hold the value returned by the function 2. A pointer to the base of the previous stack frame in the stack 3. A return address, which is the address of an instruction to execute in order to resume execution of F ’s caller after execution of F has terminated execution of 4. Parameter storage sufficient to hold the actual parameters of F 5. A set of storage locations sufficient to hold the values of variables declared locally within F USF – COP4530 – Data Structures Summer 2009 3 of 23
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon