Posted by admin on Jan 11, 2025 in Computer Engineering in Computer Engineering | 0 comments
1. Binary Search
Binary Search Using Recursion
#include <stdio.h>
int binser(int [], int low, int high, int key); // declaration
int main() {
int n;
printf("Enter array size: ");
scanf("%d", &n);
int arr[n];
printf("Enter array in sorted order:\n");
for(int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int key;
printf("Enter element to search: ");
scanf("%d", &key);
int found = binser(arr, 0, n - 1, key);
if(found == -1) {
Read More