Question: *PYTHON* Function find(a,e) with two inputs: an integer array a, sorted in increasing order, and an integer e. This function must return the index into

*PYTHON*

Function find(a,e) with two inputs: an integer array a, sorted in increasing order, and an integer e. This function must return the index into a of the first instance of the element e in the array or -1 if the element is not present. Binary search is fast so I write the following slight modification to binary search.

Is this algorithm correct? (Prove your claim.)

What is its runtime in the worst case? (Prove your claim.)

*PYTHON* Function find(a,e) with two inputs: an integer array a, sorted in

1 def bsf(a,e): 2 1,h = 0, len(a)-1 while I

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!