Содержание
- 2. Computing Factorial factorial(0) = 1; factorial(n) = n*factorial(n-1); n! = n * (n-1)! ComputeFactorial
- 3. Computing Factorial factorial(4) animation factorial(0) = 1; factorial(n) = n*factorial(n-1);
- 4. Computing Factorial factorial(4) = 4 * factorial(3) animation factorial(0) = 1; factorial(n) = n*factorial(n-1);
- 5. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) animation factorial(0) =
- 6. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 7. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 8. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 9. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 10. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 11. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 12. Computing Factorial factorial(4) = 4 * factorial(3) = 4 * 3 * factorial(2) = 4 *
- 13. Trace Recursive factorial animation Executes factorial(4)
- 14. Trace Recursive factorial animation Executes factorial(3)
- 15. Trace Recursive factorial animation Executes factorial(2)
- 16. Trace Recursive factorial animation Executes factorial(1)
- 17. Trace Recursive factorial animation Executes factorial(0)
- 18. Trace Recursive factorial animation returns 1
- 19. Trace Recursive factorial animation returns factorial(0)
- 20. Trace Recursive factorial animation returns factorial(1)
- 21. Trace Recursive factorial animation returns factorial(2)
- 22. Trace Recursive factorial animation returns factorial(3)
- 23. Trace Recursive factorial animation returns factorial(4)
- 24. factorial(4) Stack Trace
- 25. Other Examples f(0) = 0; f(n) = n + f(n-1);
- 26. Fibonacci Numbers Fibonacci series: 0 1 1 2 3 5 8 13 21 34 55 89…
- 27. Fibonacci Numbers #include using namespace std; int fib(int n) { if (n return n; return fib(n
- 28. Fibonnaci Numbers, cont.
- 29. Characteristics of Recursion All recursive methods have the following characteristics: One or more base cases (the
- 30. Problem Solving Using Recursion Let us consider a simple problem of printing a message for n
- 31. Recursive Selection Sort Find the smallest number in the list and swaps it with the first
- 33. Recursive Binary Search Case 1: If the key is less than the middle element, recursively search
- 35. Скачать презентацию