| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice TestPractice Test
About Exam
hard Solved by 2 students
Quicksort Partition Method Execution
< Prev
Next >

After executing partition on the array {9, 3, 4, 8, 2} with low = 0 and high = 4, what is the state of the array?

public class QuickPartition {
    public static int partition(int[] arr, int low, int high) {
         int pivot = arr[high];
         int i = low - 1;
         for (int j = low; j < high; j++) {
              if (arr[j] < pivot) {
                   i++;
                   int temp = arr[i];
                   arr[i] = arr[j];
                   arr[j] = temp;
              }
         }
         int temp = arr[i+1];
         arr[i+1] = arr[high];
         arr[high] = temp;
         return i+1;
    }
}
A

{3, 2, 4, 8, 9}

B

{2, 3, 4, 8, 9}

C

{2, 8, 4, 3, 9}

D

{9, 3, 4, 8, 2}

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy