What is the time complexity of the following recursive implementation to find the sum of digits of a number n? [code] #include<stdio.h> int

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?
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;
}
A. O(n)
B. O(1)
C. O(len(n)), where len(n) is the number of digits in n
D. O(1/2)
 

Tìm kiếm

Back
Top