Binary Search Recursion method Function
| 212 | |
| 213 | //Binary Search Recursion method Function |
| 214 | void RevBinSearch(struct array arr,int low,int high,int key) |
| 215 | { |
| 216 | int mid,x=0; |
| 217 | if(low<=high) |
| 218 | { |
| 219 | mid=(low+high)/2; |
| 220 | if(arr.A[mid]==key) |
| 221 | { |
| 222 | printf("The element is found at location %d\n",mid); |
| 223 | x=1; |
| 224 | } |
| 225 | else if(key<arr.A[mid]) |
| 226 | { |
| 227 | RevBinSearch(arr,low,mid-1,key); |
| 228 | } |
| 229 | else if(key>arr.A[mid]) |
| 230 | { |
| 231 | RevBinSearch(arr,mid+1,high,key); |
| 232 | } |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | printf("The element is not found\n"); |
| 237 | } |
| 238 | |
| 239 | } |
| 240 | |
| 241 | //Get Function |
| 242 | void Get(struct array arr,int index) |