Recursive Array Reversal
Consider the following processElements method. What is the result of calling this method on an integer array data with the initial call processElements(data, 0, data.length - 1)?
public void processElements(int[] data, int low, int high)
{
if (low < high)
{
int temp = data[low];
data[low] = data[high];
data[high] = temp;
processElements(data, low + 1, high - 1);
}
}
A
It halves the value of each element in data.
B
It sorts elements in data in descending order
C
It doubles the value of each element in data.
D
It reverses the elements in data.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE