Vidyalelo
Data Structure · Q730

Miscellaneous on Data Structures

Programming · Data Structure · question 730

Q730

What is the time complexity of the following recursive implementation to find the sum of digits of a number n? #include 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
Answer
D.
O(1/2)

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board