From 69b1ae8aad1e5b129ef40efc22fe8b5ee7980b29 Mon Sep 17 00:00:00 2001 From: Sejal Kothari <91632881+Sejzz@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:17:04 +0530 Subject: [PATCH] Create binarySearch.cpp --- algorithms/binarySearch.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 algorithms/binarySearch.cpp diff --git a/algorithms/binarySearch.cpp b/algorithms/binarySearch.cpp new file mode 100644 index 00000000..3ef63d1c --- /dev/null +++ b/algorithms/binarySearch.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +int binarySearch(int array[], int x, int low, int high){ + while(low<=high){ + int mid = (high+low)/2; + if(array[mid] == x) return mid; + + if(array[mid]