int foo(int n) //Line 1{ //Line 2 if (n == 0) //Line 3 return 0; //Line 4 else //Line 5 return n + foo(n - 1); //Line 6} //Line 7
Consider the accompanying definition of a recursive function. Which of the statements represents the base case?
A. Statements in Lines 1-6.
B. Statements in Lines 3 and 4.
C. Statements in Lines 5 and 6.
D. Statements in Lines 3, 4, and 5.
Answer: B
You might also like to view...
override specifier is added to the end of a member function declaration, what happens if the function is not specified as virtual in the parent class?
a) The function is overridden in the derived class. b) There is a compiler error. c) The function in the parent class will always be invoked.
Can the quick sort use the merge sort to compute the midpoint of an array?
a. No b. Yes c. Yes, if the array is already sorted d. Yes, for an array without duplicates
Which of the following is NOT part of the CPU?
A) The ALU B) The Instructional Pointer C) The Instruction Register D) RAM
The ____ topology is a continuous path for data with no logical beginning or ending point.
A. hypercube B. grid C. star D. ring