Sarah P.

asked • 08/08/20

Shown below is the 'Partition Algorithm' we developed.

public static void partition(int[ ] data, int pivot) {

int i=0, j=data.length-1;

int temp;

while(i<=j) {

while(data[i]<pivot) i++;

while(data[j]>pivot) j--;

if(i<=j) {

temp = data[i];

data[i] = data[j];

data[j] = temp;

i++;

j--;

}

}

}


If the following array goes through

this partition algorithm using '12' as

the pivot, predict how the array will

look like:

19 5 7 11 43 17 22 20 9 10

1 Expert Answer

By:

Patrick B. answered • 08/08/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.