1. Prove that the algorithm sum(n, m) returns ∑ m i=n i (again see Figure 5.14) for any m ≥ n. (Hint: perform induction on the value of m − n.)
2. Describe how your proof from Exercise 5.34 would change if Line 4 from the sum algorithm in Figure 5.14 were changed to return m + sum(n, m − 1) instead of n + sum(n + 1, m
Exercise 5.34
Prove that the algorithm sum(n, m) returns ∑ m i=n i (again see Figure 5.14) for any m ≥ n. (Hint: perform induction on the value of m − n.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here