Presentation is loading. Please wait.

Presentation is loading. Please wait.

PS2-Slides Function Call Diagram. PS2-Slides int Factorial(int n) { if(n == 0){ return 1; } else { return n*Factorial(n-1); } int main(void) x{ printf("%d!

Similar presentations


Presentation on theme: "PS2-Slides Function Call Diagram. PS2-Slides int Factorial(int n) { if(n == 0){ return 1; } else { return n*Factorial(n-1); } int main(void) x{ printf("%d!"— Presentation transcript:

1 PS2-Slides Function Call Diagram

2 PS2-Slides int Factorial(int n) { if(n == 0){ return 1; } else { return n*Factorial(n-1); } int main(void) x{ printf("%d! = %d",4,Factorial(4)); }

3 PS2-Slides

4

5

6 Stack Frames

7 PS2-Slides Recursive vs Iterative Functions. int Recursive_Function (int n) { if (base_case) return something; else (some_work AND call Recursive_Function(n-1)) } int Iterative_Function (int n) {int m = initial_value; while (condition_based_on m) (m = update(m)); return m; }

8 PS2-Slides

9

10

11 The Towers of Hanoi

12 PS2-Slides The Towers of Hanoi 2

13 PS2-Slides

14


Download ppt "PS2-Slides Function Call Diagram. PS2-Slides int Factorial(int n) { if(n == 0){ return 1; } else { return n*Factorial(n-1); } int main(void) x{ printf("%d!"

Similar presentations


Ads by Google