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.
1 parent 6d91bc8 commit 9cd1a8dCopy full SHA for 9cd1a8d
binary_search.java
@@ -1,6 +1,6 @@
1
class BinarySearchExample{
2
public static void binarySearch(int arr[], int first, int last, int key){
3
- int mid = (first + last)/2;
+ int mid = first + (last-first)/2;
4
while( first <= last ){
5
if ( arr[mid] < key ){
6
first = mid + 1;
0 commit comments