Hi can someone help me understand what happens in the following code when there is only one element in the array and it is not equal to key.
eg this is the input
1
0
98
This is the function for linear search using recursion.
int linearsearch(int a[], int n, int key)
{
if(n==0)
return -1;
if(a[0]==key)
return 0;
int i= linearsearch(a+1, n-1, key);
if(i==-1)
return -1;
return i+1;
}