Question: [PYTHON] Part 1: Write a recursive function called recursive_sum. This function sums all the elements of a list by a recursive method. The input of

[PYTHON]

Part 1: Write a recursive function called recursive_sum. This function sums all the elements of a list by a recursive method. The input of the function is a list and it will eventually return the sum. In each iteration, it will make the list smaller until the length of the list becomes zero. We do not want to use built-in functions to find the sum and the goal of this exercise is to practice recursion.

Part 2: Use a dictionary to speed up a recursive function that calculates Fibonacci numbers. The function is called fast_fib, and its inputs are a number and a dictionary.

Part 3: Write a recursive function called my_substring that takes a string and creates a list of all possible sub-strings. For example send it 'Houston' and it returns ['Houston', 'ouston', 'uston', 'ston', 'ton', 'on', 'n'] or ['Houston', 'Housto', 'Houst', 'Hous', 'Hou', 'Ho', 'H']

Submission:

Submit one python program which contains two of the above functions. Inside the program call the functions using two print statements with proper test inputs. For example print(fast_fib(35, my_dictionary) ; print( recursive_sum([1,33,55, 21])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!