Minh Phượng
New member
What is the time complexity of the following recursive implementation to find the sum of digits of a number n?
A. O
B. O(1)
C. O(len
), where len
is the number of digits in n
D. O(1/2)
Code:
#include<stdio.h>
int recursive_sum_of_digits(int n)
{
if(n == 0)
return 0;
return _________;
}
int main()
{
int n = 1201;
int ans = recursive_sum_of_digits(n);
printf("%d",ans);
return 0;
}
B. O(1)
C. O(len
D. O(1/2)