Skip to content

Commit

Permalink
Merge pull request bregman-arie#59 from aman2611/patch-1
Browse files Browse the repository at this point in the history
better name for variables
  • Loading branch information
Arie Bregman authored Jan 17, 2020
2 parents 85d8a56 + 5b6ea4a commit 4f1130d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions coding/python/binary_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
target = random.randint(1, 50)


def binary_search(li, le, ri, target):
if le <= ri:
mid = ri + le // 2
if li[mid] == target:
def binary_search(arr, lb, ub, target):
if lb <= ub:
mid = ub + lb // 2
if arr[mid] == target:
return mid
elif li[mid] < target:
return binary_search(li, mid + 1, ri, target)
elif arr[mid] < target:
return binary_search(arr, mid + 1, ub, target)
else:
return binary_search(li, le, mid - 1, target)
return binary_search(arr, lb, mid - 1, target)
else:
return -1

Expand Down

0 comments on commit 4f1130d

Please sign in to comment.