Question: In python 3, with screenshots please The template is like the following def binarySearch (listNumbers, low, high, key): # Test array def main(): array_for_test =
In python 3, with screenshots please

The template is like the following
def binarySearch (listNumbers, low, high, key):
# Test array def main(): array_for_test = [-8,-2,1,3,5,7,9] print(binarySearch(array_for_test,0,len(array_for_test)-1,9)) print(binarySearch(array_for_test,0,len(array_for_test)-1,-8)) print(binarySearch(array_for_test,0,len(array_for_test)-1,4)) main()
You will need to implement a recursive binarySearch() function which takes 4 arguments: listNumbers, which is an array assumed to contain elements in ascending order; low and high, which specify the range we want to search in the array; key, which is the element we are searching for. The function should return the index of the searched element if the element is found, or return -1 if the element is not in the array. Test you function as follows: # Test array def main(): array_for test -8,-2,1,3,5,7,9 print (binarySearch(array_for_test,e,len (array_for_test)-1,9)) print (binarySearch(array_for test,e,1en(array_for_test)-1,-8)) print (binarySearch (array_for_test,0,len(array_for_test)-1,4)) main() The output for these three cases should be 6, 0, -1. Use the debugger to trace the recursion calls to figure out what is happening
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
