Pesquisa binária entre dois índices
int BinarySearch(int[] arr, int low, int high, int key)
{
while (low <= high)
{
int mid = low + (high - low) / 2;
int midVal = arr[mid];
if (midVal < key) low = mid + 1;
else if (midVal > key) high = mid - 1;
else if (midVal == key) return mid;
}
return -1;
}
PrashantUnity