MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/3lxbyl/most_frequent_python_problems_and_solution/cva5c22/?context=3
r/Python • u/JohnettaHarned • Sep 22 '15
8 comments sorted by
View all comments
2
Binary search is implemented in the bisect module
bisect
bisect.bisect_left and bisect.bisect_right give insertion points for a value that will keep a list sorted. Accessing the index returned by bisect_left is equivalent to binary searching.
bisect.bisect_left
bisect.bisect_right
bisect_left
2
u/[deleted] Sep 22 '15 edited Sep 24 '15
Binary search is implemented in the
bisectmodulebisect.bisect_leftandbisect.bisect_rightgive insertion points for a value that will keep a list sorted. Accessing the index returned bybisect_leftis equivalent to binary searching.