Multiple Choice
What is wrong with the following recursive sum method? The method is supposed to sum up the values between 1 and x (for instance, sum(5) should be 5 + 4 + 3 + 2 + 1 = 15) .
Public int sum(int x)
{
If (x = = 0) return 0;
Else return sum(x - 1) + x;
}
A) the base case should return 1 instead of 0
B) the recursive case should return sum(x - 1) + 1; instead of sum(x - 1) + x;
C) the base case condition should be (x <= 0) instead of (x = = 0)
D) the recursive case should return sum(x) + 1;
E) the method should return a boolean instead of an int
Correct Answer:

Verified
Correct Answer:
Verified
Q36: Write a recursive method called numSegments(int order)
Q44: A recursive method without a base case
Q47: The Koch snowflake has an infinitely long
Q51: For the questions below, assume that int[
Q52: The following method correctly adds two ints,
Q53: The following drawing is a line using
Q54: Why is the following method one which
Q57: For the questions below, consider the following
Q59: Aside from writing recursive methods, another way
Q60: For the questions below, use the following