CSE 15 Quiz: quiz1review
Document Summary
Recall the recursive function c(n, k) in the class binomialcofficients discussed in lecture and posted on the webpage. Write a box trace of the function call c(5, 3) . Use this trace to find the value of c(5, 3) . Notice that in the full recursion tree for c(5, 3) , the value c(3: is evaluated 2 times, and c(2, 1) is evaluated 3 times. Suggest a modification to the function that would allow it to avoid computing the same values multiple times. (don t write the code, just explain it in words. ) 2)write a recursive function called sum(n) that computes the sum of the integers from 1 to n. hint: recall the recursive function fact(n) in the class factorial discussed in lecture and posted on the webpage. 2a) public static int sum(int n) { if n=1 { return 1; return n+sum(n-1);