comparisons ** approximate number of items left ** table tabular analysis for binary search def binary_search(a_listitem)if len(a_list= return false elsemidpoint len(a_list/ if a_list[midpoint=itemreturn true elseif item a_list[midpoint]return binary_search(a_list[:midpoint]itemelsereturn binary_search(a_list[midpoint :]itemtest_list [ ,print(binary_search(test_list )print(binary_search(test_list )analysis of binary search to analyze the binary search algorithmwe need to recall that each comparison eliminates about half of the remaining items from consideration what is the maximum number of comparisons this algorithm will require to check the entire listif we start with itemsabout items will be left after the first comparison after the second comparisonthere will be about then and so on how many times can we split the listtable helps us to see the answer when we split the list enough timeswe end up with list that has just one item either that is the item we are looking for or it is not either waywe are done the number of comparisons necessary to get to this point is where ni solving for gives us log the maximum number of comparisons is logarithmic with respect to the number of items in the list thereforethe binary search is (log none additional analysis issue needs to be addressed in the recursive solution shown abovethe recursive callbinary_search(a_list[:midpoint],itemuses the slice operator to create the left half of the list that is then passed to the next invocation (similarly for the right half as wellthe analysis that we did above assumed that the slice operator takes constant time howeverwe know that the slice operator in python is actually (kthis means that the binary search using slice will not perform in strict logarithmic time luckily this can be remedied by passing the list along with the starting and ending indices even though binary search is generally better than sequential searchit is important to note sorting and searching