diff --git a/src/bsrch.c b/src/bsrch.c index edba67a..58ec694 100644 --- a/src/bsrch.c +++ b/src/bsrch.c @@ -14,16 +14,15 @@ int bsrch(int target, int* arr, size_t n) { // TODO: Find a way to error if list is out of order - bool found = false; - int start = 0, end = n - 1; + int start = 0, end = (int)n - 1; if (arr[start] > target || arr[end] < target) return -1; int mid = (start + end) / 2; - while (!found) + while (true) { - if (arr[mid] == target) found = true; - if (start == end && !found) return -1; - if (mid == end && !found) return -1; + if (arr[mid] == target) break; + if (start == end) return -1; + if (mid == end) return -1; else if (arr[mid] < target) { start = mid + 1;