#include<stdio.h>
int recursive_search_num(int *arr, int num, int idx, int len)
{
if(idx == len)
return -1;
if(arr[idx] == num)
return idx;
return recursive_search_num(arr, num, idx+1, len);
}
int main()
{
int arr[8] ={1,2,3,3,3,5,6,7},num=5,len = 8;
int indx = recursive_search_num(arr,num,0,len);
printf("Index of %d is %d",num,indx);
return 0;
}
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
What is the time complexity of the following recursive implementation of linear search?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What is the time complexity of the following recursive implementation of linear search?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!