Exp 11 DS
Exp 11 DS
h>
if (arr[mid] == key) {
return mid;
}
else if (arr[mid] < key) {
left = mid + 1;
}
else {
right = mid - 1;
}
}
return -1;
}
int main() {
int arr[8], key1, key2, result1, result2;
if (result1 != -1)
printf("Element %d found at index %d.\n", key1, result1);
else
printf("Element %d not found.\n", key1);
if (result2 != -1)
printf("Element %d found at index %d.\n", key2, result2);
else
printf("Element %d not found.\n", key2);
return 0;
}