block by joyrexus 469105714e82c101f014

Binary search

Binary search implementation in python.

Usage

from binary_search import search

arr = [2, 3, 4]

key = 3
i = search(arr, key)    # returns index of key value if found
assert arr[i] == key

key = 5
i = search(arr, key)    # returns `None` if key value is not found
assert i == None

binary_search.py

test.py