We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ca73caf commit 32c00ffCopy full SHA for 32c00ff
RECURSIVE_BI.java
@@ -0,0 +1,11 @@
1
+public int binarySearch(int[] a, int start, int end, int target) {
2
+ if(start > end)
3
+ return -1;
4
+ int mid = start + (end - start) / 2;
5
+ if(a[mid] == target)
6
+ return mid;
7
+ else if(a[mid] > target)
8
+ return binarySearch(a, start, mid-1, target);
9
+ else
10
+ return binarySearch(a, mid+1, end, target);
11
+ }
0 commit comments