| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Feb | ||||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | ||||||
Chapter 12, 12.1
1. What keeps a recursive definition from being circular?
-Assign a value to the base case, the starting point of recursive.
2. What are the two parts of any recursive method?
-One part is the function to define any specific spot of the number sequence, and the other part is the initialized value of the starting point.
3. Why is recursion more expensive than iteration?
-It takes a certain amount of memory space and keep it from freedom of usage by other program during the whole time of processing.
4. What are the benefits of using recursion?
-It’s clearer, shorter, and more elegant solution to a programming task than the iteration methods. It’s a more useful techniques.
5. Consider the following definition of the method raise, which raises a given number to a given exponent:
Draw a trace of the complete execution of raise (2,5)
- 2 * raise (2,4)–> 2*2*raise(2,3)–> 2*2*2*raise(2, 2)–> 2*2*2*2*raise(2,1)–> 2*2*2*2*2*raise(2,0)–>2*2*2*2*2*1= 32
6. Consider the following method:
What happens during the execution of whatAMethod(3):
-It’s an infinite recursive. It goes forever.