MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / binary_search

Function binary_search

Python/CP_Templates.py:177–185  ·  view source on GitHub ↗
(i, li)

Source from the content-addressed store, hash-verified

175
176
177def binary_search(i, li):
178 fn = lambda x: li[x] - x // i
179 x = -1
180 b = len(li)
181 while b >= 1:
182 while b + x < len(li) and fn(b + x) > 0: # Change this condition 2 to whatever you like
183 x += b
184 b = b // 2
185 return x

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected