int firstOcc(int *arr, int s, int e, int k){
int ans;
while(s<=e){
int mid=(s+e)/2;
if(arr[mid]==k){
ans=mid;
e=mid-1;
}
else if(arr[mid]<k){
s=mid+1;
}
else{
e=mid-1;
}
}
return ans;
}
How to convert this into recursive code. Please give a step by step explanation (return type of function int) don’t copy paste from somewhere else.