In Python, which of the following is a correct implementation of binary search?
-
def binary_search(arr, x): ...
-
def binary_search(arr, x): return arr.index(x)
-
def binary_search(arr, x): for i in arr: if i == x: return i
-
def binary_search(arr, x): while arr: ...