About 198,000 results
Open links in new tab
  1. Binary search (bisection) in Python - Stack Overflow

    Oct 17, 2008 · While there's no explicit binary search algorithm in Python, there is a module - bisect - designed to find the insertion point for an element in a sorted list using a binary search.

  2. Recursion binary search in Python - Stack Overflow

    Here's an elegant recursive solution if you're: 1) Trying to return the INDEX of the target in the original list being passed in, before it is halved. Getting the target is the easy part. 2) Only …

  3. Binary search algorithm in python - Stack Overflow

    Feb 29, 2012 · I am trying to implement the binary search in python and have written it as follows. However, I can't make it stop whenever needle_element is larger than the largest element in …

  4. python - Binary search through strings - Stack Overflow

    Dec 17, 2015 · I'm relatively new to python(3.3) and I'm just trying to do a binary search through a list of words, and cant figure out how to fix my operand types when it comes down to looping …

  5. Binary search in a Python list - Stack Overflow

    Jul 13, 2016 · I am trying to perform a binary search on a list in python. List is created using command line arguments. User inputs the number he wants to look for in the array and he is …

  6. Python dictionary - binary search for a key? - Stack Overflow

    Oct 10, 2014 · In order to do this, I need to be able to do a search (ideally binary, rather than naively looping through every key in the dictionary). I have searched for bsearch dictionary key …

  7. python - How to do a binary search for a range of the same value ...

    Jun 12, 2015 · How to do a binary search for a range of the same value? Asked 10 years, 3 months ago Modified 1 year, 8 months ago Viewed 3k times

  8. Get index of closest value with binary search - Stack Overflow

    May 15, 2014 · I want to do a binary search in python: def binarySearch(data, val): Where data is a sorted array and value is the value being searched for. If the value is found, I want to return …

  9. python - Binary search to insert a value to a sorted list - Stack …

    Jun 18, 2020 · To improve your code, look at trincot's answer; but as he also said, be aware that using a binary search for each element of B is probably not the most efficient method here. …

  10. python - Binary Search on Sorted List with Duplicates - Stack …

    Jan 5, 2022 · To learn divide-and-conquer algorithms, I am implementing a function in Python called binary_search that will get the index of the first occurrence of a number in a non-empty, …