From 5b6ea4aaad75be4c44fe56bf2d2df6cb07d3d065 Mon Sep 17 00:00:00 2001 From: aman2611 Date: Fri, 17 Jan 2020 18:15:07 +0530 Subject: [PATCH] better name for variables --- coding/python/binary_search.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/coding/python/binary_search.py b/coding/python/binary_search.py index 0efe132..2fd753c 100644 --- a/coding/python/binary_search.py +++ b/coding/python/binary_search.py @@ -6,15 +6,15 @@ rand_num_li = sorted([random.randint(1, 50) for _ in range(10)]) 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