Question: ***USE PYTHON*** Some Advice on Writing Recursive Functions Many students find it helpful when writing recursive functions to first write the function using iteration (loops).

***USE PYTHON***

Some Advice on Writing Recursive Functions Many students find it helpful when writing recursive functions to first write the function using iteration (loops). Doing so helps them to figure out the basic algorithm for solving the problem that can be transformed into a recursive solution. However, your final solutions MUST NOT not be iterative. Use of loops for a function will result in 0 points for that function. Part I: Sum of Odd Integers (2 points) Write a recursive function sum odds() that takes a non-empty list of integers as an argument and returns the sum of only the odd integers in the list. In class we explored a recursive function called rsum() that recursively computes the sum of a list of integers use it as a model to get started. Your function must be recursive and must not use any loops. Examples:

***USE PYTHON*** Some Advice on Writing Recursive Functions Many students find it

helpful when writing recursive functions to first write the function using iteration

(loops). Doing so helps them to figure out the basic algorithm for

solving the problem that can be transformed into a recursive solution. However,

your final solutions MUST NOT not be iterative. Use of loops for

Function Call Return Value sum odds 1, 8, 5, 6, 3, 4, 9]) 18 sum odds 15 sum odds (12, 6, 4, 8, -2, -201) 0 Part II: Drop Every n-th Element (2 points) Write a recursive function drop that takes a non-empty list of integers and a positive integer n as its argu- ments, and returns a new list formed by dropping every n-th item from the original list. You may assume that m 1. Your function must be recursive and must not use any loops. Examples: Function Call Return Value drop (10, 1, 2, 3, 4, 5, 6, 7, 8 3) 10, 1, 3, 4, 6, 71 6, 8, 10, 12, 141, 2) [2, 6, 10, 141 drop (12, 4, drop 8 6, 7 4) 6, 7

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!