fundean
Feb 4th, 2004, 09:51 AM
public static boolean binarySearch (int[] data, int min,
int max, int value)
{
boolean result;
int midpoint = (min + max) / 2; // determine the midpoint
if (data[midpoint].compareTo(value) == 0)
result = true;
else if (data[midpoint].compareTo(value) > 0)
{
if (min <= midpoint - 1)
result = binarySearch(data, min, midpoint - 1, value);
else
result = false;
}
else if (midpoint + 1 <= max)
result = binarySearch(data, midpoint + 1, max, value);
else
result = false;
return result;
}//method binarySearch
this code gives me the following error:
"int cannot be dereferenced". Can anyone suggest a possible fix?
Thanks !
int max, int value)
{
boolean result;
int midpoint = (min + max) / 2; // determine the midpoint
if (data[midpoint].compareTo(value) == 0)
result = true;
else if (data[midpoint].compareTo(value) > 0)
{
if (min <= midpoint - 1)
result = binarySearch(data, min, midpoint - 1, value);
else
result = false;
}
else if (midpoint + 1 <= max)
result = binarySearch(data, midpoint + 1, max, value);
else
result = false;
return result;
}//method binarySearch
this code gives me the following error:
"int cannot be dereferenced". Can anyone suggest a possible fix?
Thanks !