Question: Write a function that implements bisection search on a given list. For this part, you need to use the same list containing the 10,000 random

Write a function that implements bisection search on a given list. For this part, you need to use the same list containing the 10,000 random elements which you used in the previous exercise.

This function should take inputs as:

a number to be searched in the list,

and the list itself.

The output is true or false and the time required to perform that search:

if the number is found in the list return true, otherwise return false.

Also, measure the time needed to run this function and compare it with linear search.

Note that to use bisection search, the list should be sorted (otherwise, you may not get a correct result).

Therefore, before calling bisection search function, you need to sort the list first to make sure that the input is sorted (you can use built-in sort function for the list; i.e. L.sort() which will perform in-place sort)

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!