Select The Lesson:
Welcome to Online Education Of Sri Lanka
/*eduLanka Online education web site of Sri Lanka -------- w w w . e d u L a n k a . c o m ------------ java programs for University students - who follow courses - BIT - SLIIT and more find more lessons in http://www.it.edulanka.com eduLanka@gmail.com this programs under GNU licence */ import TerminalIO.*; class Bsearch { public static void main(String arg[]) { KeyboardReader reader=new KeyboardReader(); int n,data,x,i; n=reader.readInt("how many element are u enter :"); int[] arr=new int[n]; System.out.println("Enter an integer:"); for(i=0;i0) System.out.println("Find at "+(y+1)); else System.out.println("Not find"); } public static void bsort(int array[]) { int temp; for(int i=array.length;i>0;i--) { for(int j=0;jarray[j+1]) { temp=array[j]; array[j]=array[j+1]; array[j+1]=temp; } } } } public static int binarysearch(int list[],int key) { int left,right,midpt,size; size=list.length; left=0; right=size-1; while(left<=right) { midpt=(int)((left+right)/2); if(key==list[midpt]) { return midpt; } else if(key>list[midpt]) left=midpt+1; else right=midpt-1; } return -1; } }