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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site