From f50a6288d6054dd3a08e6e54745a096e7ff550bf Mon Sep 17 00:00:00 2001 From: Souma Kanti Ghosh <40127554+SubCoder1@users.noreply.github.com> Date: Tue, 16 Oct 2018 17:49:13 +0530 Subject: [PATCH] Binary Search implementation in Python 3 --- binary_search/python/update_binary_search.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/binary_search/python/update_binary_search.py b/binary_search/python/update_binary_search.py index 1705a5e7..cec5fb1f 100644 --- a/binary_search/python/update_binary_search.py +++ b/binary_search/python/update_binary_search.py @@ -1,10 +1,10 @@ -def binarySearch(array, value): - start = 0 - end = len(array) +def b_Search(array, value): + sTart = 0 + eNd = len(array) found = False pos = None - while start <= end and not found : - mid = (start + end) // 2 + while sTart <= eNd and not found : + mid = (sTart + eNd) // 2 if value == array[mid] : found = True ; pos = mid elif value < array[mid] : end = mid - 1 else : start = mid + 1 @@ -15,5 +15,5 @@ def binarySearch(array, value): data = list(map(int, input().split())) data.sort() print("Enter the element to be searched in the data given -- ", end='') -val = int(input()) -binarySearch(data,val) +element = int(input()) +b_Search(data,element)