The order of growth for the depth of recursion associated with the recursive factorial (returns N!) method
explain how to get correct answer for the following question
Given that (n!=1 if n=0, n!=n x (n-1) x (n-2) x ... x 1) The order of growth for the depth of recursion associated with the recursive factorial (returns N!) method is: A. O(N) B. O(N^2) C. O(log2N). D. O(1).
Given the following code, what are the constraints on the input argument?
int mystery(int num){
if (num == 0) return 0;
else
if (num > 100) return -1;
else
return num + mystery(num – 1);
}
The number of recursive calls that a method goes through before returning is called: A. order of growth efficiency. B. the depth of recursion.
C. combinatorial recursive count.
The following code is supposed to return the sum of the numbers between 1 and n inclusive, for positive n. An analysis of the code using the "Three Question" approach reveals that:
int sum(int n){
if (n == 1)
return 1;
else
return (n + sum(n));
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps