Vidya DAA Lab 1
Vidya DAA Lab 1
int main()
int n;
cin >> n;
int arr[n];
int key;
if (ans == -1)cout << "The element " << key << " is not found."<< endl;
else cout << "The element " << key << " is found at " << ans << " index of the given array." << endl;
return 0;}
Output:
Recursive Binary Search Program
#include <iostream> NAME: Vidya Thakur
using namespace std; ROLL NO.: 2200320130192
int binarysearch(int *arr,int l,int h,int key){
int m = (l+h)/2;
if(arr[m]==key)return m;
int main()
{ int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
int k;
cin>>k;
Output: