diff --git a/Search/binary_search_vish35.cpp b/Search/binary_search_vish35.cpp new file mode 100644 index 0000000..bc60884 --- /dev/null +++ b/Search/binary_search_vish35.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; +typedef long long ll; +int binarySearch(int a[],int l,int r,int x) +{ + if(l>r) + return -1; + int mid=(l+r)/2; + if(a[mid]==x) + return mid; + if(a[mid]>N; + int a[N]; + for(int i=0;i>a[i]; + } + int x;cin>>x; + int res=binarySearch(a,0,N-1,x); + if(res==-1) + cout<<"Not found"; + else + cout<<"found at "< +using namespace std; +typedef long long ll; +int next_gap(int n) +{ + if(n<=1) + return 0; + return (n/2)+(n%2); +} +int main() +{ + ll t; + cin>>t; + while(t--) + { + ll n,m; + cin>>n>>m; + int a[n],b[m]; + for(int i=0;i>a[i]; + for(int i=0;i>b[i]; + int gap=n+m; + int i,j; + for(gap=next_gap(gap);gap>0;gap=next_gap(gap)) + { + for(i=0;i+gapa[i+gap]) + swap(a[i],a[i+gap]); + } + for(j=gap>n?gap-n:0;ib[j]) + swap(a[i],b[j]); + } + if(jb[j+gap]) + swap(b[j],b[j+gap]); + } + } + } + for(int i=0;i