Module pywander.algorithm.binary_search

Functions

def binary_insert(seq, target)

use the insort_left

use the bisect_left.

def binary_search_func(seq, target, func=<function <lambda>>, round_n=4, approx=True)

use binary search to solve f(x) = target problem, if the function is a monotonic function.

seq list or tuple target found target in which case is the f(x) = target func the monotonic function round_n accurate to how many decimal point approx the approx mode if approx=True found target or some nearly target, return it's index if approx=False found target index otherwise return -1