summaryrefslogtreecommitdiff
path: root/BS/baselines/gpu/cpu_lib.py
diff options
context:
space:
mode:
Diffstat (limited to 'BS/baselines/gpu/cpu_lib.py')
-rw-r--r--BS/baselines/gpu/cpu_lib.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/BS/baselines/gpu/cpu_lib.py b/BS/baselines/gpu/cpu_lib.py
new file mode 100644
index 0000000..9a45f94
--- /dev/null
+++ b/BS/baselines/gpu/cpu_lib.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+def binary_search(arr, search):
+
+ L = 0
+ R = len(arr)
+
+ while(L<=R):
+
+ if L>R:
+ return -1 #Error code 1
+
+ m = (L+R)/2
+ if(arr[m] < search):
+ L = m+1
+ elif(arr[m] > search):
+ R = m-1
+ else:
+ return m
+
+ return -2 #Error code 2 \ No newline at end of file