c is the code usedSolution3 int binarySearchint a int sizein
(c++ is the code used)
Solution
3)
int binarySearch(int a[] ,int size,int k)
{
int low=0,high=size-1;
int mid=(low+high)/2;
while(1){
if(a[mid]==k)
return mid;
else if(a[mid] < k){
low=mid;
}
else
high=mid-1;
}
return -1;
}
The above code checks for the available occurence of the given key value \'k\' and by using the binary search method implemented above searching was done ...
4)
void mysort(int a[],int len)
{
for(int i=0;i<len;i++){
for(int j=i+1;j<len;j++){
if(a[i] > a[j] ){
a[i]=a[i]+a[j];
a[j]=a[i]-a[j];
a[i]=a[i]-a[j];
}
}
}
}
Here by using the bubble sort method the elements in the given array are sorted in the array...
![(c++ is the code used)Solution3) int binarySearch(int a[] ,int size,int k) { int low=0,high=size-1; int mid=(low+high)/2; while(1){ if(a[mid]==k) return mid; el (c++ is the code used)Solution3) int binarySearch(int a[] ,int size,int k) { int low=0,high=size-1; int mid=(low+high)/2; while(1){ if(a[mid]==k) return mid; el](/WebImages/12/c-is-the-code-usedsolution3-int-binarysearchint-a-int-sizein-1009756-1761521111-0.webp)
![(c++ is the code used)Solution3) int binarySearch(int a[] ,int size,int k) { int low=0,high=size-1; int mid=(low+high)/2; while(1){ if(a[mid]==k) return mid; el (c++ is the code used)Solution3) int binarySearch(int a[] ,int size,int k) { int low=0,high=size-1; int mid=(low+high)/2; while(1){ if(a[mid]==k) return mid; el](/WebImages/12/c-is-the-code-usedsolution3-int-binarysearchint-a-int-sizein-1009756-1761521111-1.webp)