Skip to content

Commit

Permalink
Binary Search implementation in Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
SubCoder1 committed Oct 16, 2018
1 parent 30f3f2b commit f50a628
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions binary_search/python/update_binary_search.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

0 comments on commit f50a628

Please sign in to comment.