| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
medium Solved by 2 students
Recursive Array Reversal
< Prev
Next >

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.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy