#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)
What is the time complexity of the following recursive implementation to find the sum of digits of a number n?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What is the time complexity of the following recursive implementation to find the sum of digits of a number n?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!