Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments. What statement should be used to complete the recursive method? public static void reversePrint(int[] array, int firstIndex, int lastIndex)
{
If (firstIndex < lastIndex)
{
________________________________________
}
System.out.println(array[firstIndex]) ;
}
Public static void main(String[] args)
{
Int [] numbers = { 4, 7, 1, 0, 2, 7 };
ReversePrint(numbers, 0, numbers.length - 1) ;
}
A) reversePrint(array, firstIndex, lastIndex + 1) ;
B) reversePrint(array, firstIndex, lastIndex - 1) ;
C) reversePrint(array, firstIndex + 1, lastIndex - 1) ;
D) reversePrint(array, firstIndex + 1, lastIndex) ;
Correct Answer:
Verified
Q57: Consider the method powerOfTwo shown below: public
Q58: Complete the code for the myFactorial recursive
Q59: Complete the code for the calcPower recursive
Q60: Complete the following code snippet, which is
Q61: Consider the recursive square method shown below
Q63: Complete the following code snippet, which is
Q64: Consider the problem of displaying a pattern
Q65: Complete the following code snippet, which is
Q66: A palindrome is a word or phrase
Q67: Consider the fib method from the textbook
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents