CSE 15 Quiz: quiz1review

293 views4 pages
11 Oct 2016
School
Course
Professor

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);

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents