with our new index of index_of_first_element and index_of_last_element now being and respectivelywe compute the mid ( )/ which equals the new midpoint is we find the middle item and compare with the search itemordered_list[ which yields the value voilaour search term is found this reduction of our list size by halfby re-adjusting the index of the index_of_first_element and index_of_last_element continues as long as index_of_first_element is less than index_of_last_element when this fails to be the case it is most likely that our search term is not in the list the implementation here is an iterative one we can also develop recursive variant of the algorithm by applying the same principle of shifting the pointers that mark the beginning and ending of the search list def binary_search(ordered_listfirst_element_indexlast_element_indexterm)if (last_element_index first_element_index)return none elsemid_point first_element_index ((last_element_index first_element_index if ordered_list[mid_pointtermreturn binary_search(ordered_listfirst_element_indexmid_point- ,termelif ordered_list[mid_pointtermreturn binary_search(ordered_listmid_point+ last_element_indextermelsereturn mid_point