public class BinarySearch   
{
    /**
       Durchsuchen des Bereichs l[k] fuer i<=k<=j 
    */


    private static boolean sucheVonBis(Comparable[] l, Object w, int i, int j)
    {
	if (i > j) return false;
	if (i == j) return 0 == l[i].compareTo(w);
	int m = (i+j) / 2;
	Comparable wm = l[m];
	int comp = wm.compareTo(w);
	if (comp == 0) return true;
	if (comp < 0) // wm < w
	    return sucheVonBis(l,w,m+1,j);
	else
	    return sucheVonBis(l,w,i,m-1);
    }

    public static boolean sucheRec(Comparable[] l, Object w) {
	return sucheVonBis(l,w,0,l.length-1);
    }

    public static boolean sucheIter(Comparable[] l, Object w) {
	int i = 0;
	int j = l.length-1; 
	boolean gefunden = false;
	while(!gefunden && i < j) {
	    int m = (i + j)/2;
	    Comparable wm = l[m];
	    int comp = wm.compareTo(w);
	    if (comp == 0) gefunden = true;
	    else if (comp < 0)
		i = m + 1;
	    else
		j = m - 1;
	}
	return gefunden;
    }

	     
	

}
