1 
ic01 
CS8 W19 
Name:  

(as it would appear on official course roster)  
Umail address:  @umail.ucsb.edu  section 

Optional: name you wish to be called if different from name above.  
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" 
ic01: Perkovic 10.1 and 10.2 (Recursion)
ready?  assigned  due  points 

true  Tue 03/12 02:00PM  Tue 03/12 09:00AM 
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the lowest scores (if you have zeros, those are the lowest scores.)
Please:
 No Staples.
 No Paperclips.
 No folded down corners.
Read Chapter 10, sections 10.1 and 10.2 and the lecture notes.
(10 pts) Please fill in the information at the top of this homework sheet, as usual. WRITE DARK, and remember, if you MUST submit it on multiple sheets, JUST write your name at the top of both sheets and turn in both sheets UNCONNECTED. No staples, paper clips, fold/tear etc or anything that would jam up the scanner.

(10 pts) What is the significance of a “base case” in a recursive function?

(40 pts) Read the description of the following function. Provide a recursive implementation of the function.
def recursiveSum(lst): ''' Assume lst is a list of numbers. Compute the sum of all the elements in the list Your solution must use recursion ''' # Write the base case: empty list # Write the recursive case: list with one or more elements

(40 pts) Read the description of the following function. Write two test cases and provide a recursive implementation of the function.
def recursiveDigitSum(n): ''' Computes the sum of digits of a positive integer n Your solution must use recursion ''' # Write the base case: n is a single digit number # Write the recursive case: n is more than one digit # Write your test cases below: