Question
Pls help me write the following function in python (pls include commented explanation) Function name (8): find_index Parameters: sorted_list, target Return value: the index of
Pls help me write the following function in python (pls include commented explanation)
Function name (8): find_index Parameters: sorted_list, target Return value: the index of the target Description: Write a function called find_index that accepts two parameters, a sorted list of numbers and a target number (numbers can be integers or floats.) Use recursion to implement binary search on the sorted list of numbers and return the index of the target if it is in the list, or -1 if it is not in the list. You will not receive credit if you dont use recursion.
Test Cases (not an exhaustive list):
>>> find_index([3, 5, 7, 9, 20], 9) 3
>>> find_index([4, 5, 6.2], 4) 0
>>> find_index([1, 2, 3], 10)
-1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started