Question: Python Questions - Coding with RECURSION 1) Write a function called maxList(L) that takes a list as argument and (using a recursive process) returns the
Python Questions - Coding with RECURSION
1)
Write a function called maxList(L) that takes a list as argument and (using a recursive process) returns the largest item in the list. E.g. maxList( [5,7,4,6,4,2,8,3] ) 8
2)
Write a function count(s, token) that takes two strings as argument, a source, and a token. The function should use a recursive process to count the number of times the token appears in the given string. For simplicity, you may assume the token is only a single character long. For a greater challenge, allow for any sized token. E.g. count("Hello World!", "o") 2
3)
Write a function called f(n) that computes the nth number in the series defined by the following function:
() = { , if x<3 3 ( 1) + 2 ( 2) + ( 3), if x < 3,
E.g. : f(1) 1 f(7) 1382 f(25) 16336148470525
For an extra challenge, try expressing this function using iteration (i.e., using a for or while loop).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
