Q1:
bool BinarySearch(int *arr, int s, int e, int k) { if (s > e) return false; int mid = s + (e - s) / 2; if(arr[mid] == k) return true; if(arr[mid] > k) return BinarySearch(arr, 0, mid-1, k); else return BinarySearch(arr, mid+1, e, k); }
Last updated 6 months ago
Was this helpful?