I think I'm in an endless loop in my binary search code. I'm passing in the empID, so it can return the subscript for the mid but its not returning anything.
public int binSearch(int empID)
{
int first = 0;
int last = empCount - 1;
int found = 0;
int mid = 0;
while (first <= last && found == 0)
{
mid = (first + last) / 2;
if (empNums[mid] == empID)
{
found = 1;
}
else
{
if (empNums[mid] < empID)
{
first = mid + 1;
}
else
{
last = mid - 1;
}
}
while (found == 0)
{
mid = -1;
}
}
return mid;
}
while (found == 0) mid = -1;you definitely don't want this.