We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 95da8b7 + 4724cd0 commit 71001bfCopy full SHA for 71001bf
searching/BinarySearch.py
@@ -0,0 +1,12 @@
1
+def binarySearch(alist, item):
2
+2 if len(alist) == 0:
3
+3 return False
4
+4 else:
5
+5 midpoint = len(alist)//2
6
+6 if alist[midpoint]==item:
7
+7 return True
8
+8 else:
9
+9 if item<alist[midpoint]:
10
+10 return binarySearch(alist[:midpoint],item)
11
+11 else:
12
+12 return binarySearch(alist[midpoint+1:],item)
0 commit comments