Question: python pls and this is what i have so far : L=[1,2,3,4,5,6,7] def myRSearch(L,v): if len(L) == 0: return -1 elif L[0] == v :
python pls and this is what i have so far :
L=[1,2,3,4,5,6,7] def myRSearch(L,v): if len(L) == 0: return -1 elif L[0] == v : return 0 else: return 1 + myRSearch(L[1:], v)
5. Function Three: myRSearch Specification: Assume you are given a sorted list of integers to search. Your job is to write a search algorithm to find the index of a particular number The third function you will write should be called 'myRSearch'. Your function should take two (2) arguments: an integer to search for and a sorted list of integers. The function should return one (1) integer, the index in the input list containing the input integer. If the input integer does not exist in the list, your function should return -1 For credit, you MUST NOT use either a for or a while loop. This search algorithm MUST be recursive. There should be at least one call to itself in the body of the function or you will get no credit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
