better name for variables

This commit is contained in:
aman2611 2020-01-17 18:15:07 +05:30 committed by GitHub
parent 85d8a566d1
commit 5b6ea4aaad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,15 +6,15 @@ rand_num_li = sorted([random.randint(1, 50) for _ in range(10)])
target = random.randint(1, 50) target = random.randint(1, 50)
def binary_search(li, le, ri, target): def binary_search(arr, lb, ub, target):
if le <= ri: if lb <= ub:
mid = ri + le // 2 mid = ub + lb // 2
if li[mid] == target: if arr[mid] == target:
return mid return mid
elif li[mid] < target: elif arr[mid] < target:
return binary_search(li, mid + 1, ri, target) return binary_search(arr, mid + 1, ub, target)
else: else:
return binary_search(li, le, mid - 1, target) return binary_search(arr, lb, mid - 1, target)
else: else:
return -1 return -1