Last active
May 25, 2019 21:34
-
-
Save maksadbek/9d66c2c93c7d2379e290ac90e3a49f9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search(arr, l, r, x): | |
if r >= l: | |
mid = int(l + (r - l)/2) | |
if len(arr) <= mid: | |
return mid | |
if arr[mid] == x: | |
return r, mid | |
elif arr[mid] > x: | |
return search(arr, l, mid-1, x) | |
else: | |
return search(arr, mid + 1, r, x) | |
else: | |
return -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment