fix infinite loop for some numbers in binary search

This commit is contained in:
Roland W-H 2022-05-26 15:28:47 +01:00
parent ecdcdc2821
commit e260cf38dc
1 changed files with 1 additions and 0 deletions

View File

@ -23,6 +23,7 @@ int bsrch(int target, int* arr, size_t n)
{
if (arr[mid] == target) found = true;
if (start == end && !found) return -1;
if (mid == end && !found) return -1;
else if (arr[mid] < target)
{
start = mid + 1;