LINEAR
LINEAR
LINEAR
Flowchart:
Source Code:
#include <stdio.h>
if (arr[mid] == key) {
return mid; // Return the index if the key is found
} else if (arr[mid] < key) {
low = mid + 1; // Search in the right half
} else {
high = mid - 1; // Search in the left half
}
}
int main() {
int arr[] = {2, 5, 8, 12, 16, 23, 38, 45, 50};
int n = sizeof(arr) / sizeof(arr[0]);
int key;
printf("Enter the element to search: ");
scanf("%d", &key);
return 0;
}
OUTPUT :