The following code is how I'm trying to create a recursive binary method..
public static int binarySearch(Comparable[] objArray, Comparable item)
{
int lower=0;
int upper=objArray.length -1;
int i = -1;
int compareResult;
boolean found = false;
while ((lower<=upper) && (!found))
{
i=(lower+upper)/2;
compareResult=item.compareTo(objArray[i]);
if(compareResult<0)
{
upper=i-1;
}
else
if (compareResult>0)
{
lower=i+1;
}
else
{
found=true;
}
}
return compareResult;
}
I feel as thought I'm not doing this correctly...any suggestions?
-D