Write a recursive method that takes 3 parameters: an integer array a, and two integers first and last. The method will find the largest value in a between indices first and last, inclusive. That is, it will return the largest value in the part of the array a[first..last] . You may assume that first ? last.

What will be an ideal response?



public static int findMax(int [] a, int first, int last)
{
if (first == last)
return a[first];

int firstValue = a[first];
int maxOfRest = findMax(a, first + 1, last);

if (firstValue > maxOfRest)
return firstValue;
else
return maxOfRest;
}

Computer Science & Information Technology

You might also like to view...

CHAP, an encrypted authentication method that uses what file hashing algorithm.

What will be an ideal response?

Computer Science & Information Technology

Redirect the output of an ls –l command to a file named ls.out. Display ls.out using cat.

What will be an ideal response?

Computer Science & Information Technology

Videos are commonly transmitted using streaming, where a small segment of the file is transmitted and begins to play while the server sends the next segment.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

SIP proxy servers are used in ________.

transport transmissions signaling transmissions Both transport transmissions and signaling transmissions Neither transport transmissions nor signaling transmissions

Computer Science & Information Technology