package arrays;
import java.util.Scanner;
public class binarySearch
public static void search(int[] arr,int item) {
int low=0;
int high=arr.length-1;
while(low<=high) {
int mid=(low+high)/2;
if (arr[mid]>item) {
high=mid-1;
}
else if(arr[mid]<item) {
low=mid+1;
}
else if (arr[mid]==item) {
System.out.println(mid);
}
else
System.out.println("not found");
}
}
public static void main(String[] args) {
int[] arr= {4,6,3,8,7,9};
System.out.println("enter the element to be searched\n");
Scanner s=new Scanner(System.in);
int n=s.nextInt();
search(arr,n);
}
}