Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago