Sha256: 9584a6463d2a3db14d57d94d48b82b67dd75b1de2862f3416dc815268b02e989
Contents?: true
Size: 363 Bytes
Versions: 396
Compression:
Stored size: 363 Bytes
Contents
def binary_search(search_list, value): low = 0 high = len(search_list) - 1 while low <= high: middle = (low + high) // 2 if search_list[middle] > value: high = middle - 1 elif search_list[middle] < value: low = middle + 1 else: return middle raise ValueError("Value not found.")
Version data entries
396 entries across 396 versions & 1 rubygems