From 95cabcf733101a8f506ea63b358786f60575109f Mon Sep 17 00:00:00 2001 From: Surendra1979 <117038116+Surendra1979@users.noreply.github.com> Date: Mon, 31 Oct 2022 00:36:27 +0530 Subject: [PATCH] Binary search using function --- c/Binarysearch.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 c/Binarysearch.c diff --git a/c/Binarysearch.c b/c/Binarysearch.c new file mode 100644 index 0000000..d960f80 --- /dev/null +++ b/c/Binarysearch.c @@ -0,0 +1,69 @@ +#include +int binarySearch(int arr[] , int left , int right , int item ){ + int mid ; + if (right >= left){ + mid = (left+ right )/2; + if (arr[mid ]==item){ + return mid +1 ; +} else if (arr[mid]arr[i+1]){ + hsum= hsum+(arr[i+1]-arr[i]); + } + + + } + + sum=hsum; + k++; + } + printf("%d ", k); + + } + + + + + return 0; +} +