Question: The following code is supposed to return n!, for positive n. An analysis of the code using our Three Question approach reveals that: int factorial
The following code is supposed to return n!, for positive n. An analysis of the code using our "Three Question" approach reveals that:
int factorial (int n){
if (n > 0)
return (n * factorial(n - 1));
}
| A) | it fails the base-case question. | |
| B) | it fails the smaller-caller question. | |
| C) | it fails the general-case question. | |
| D) | it passes on all three questions and is a valid algorithm. | |
| E) | None of these is correct. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
