Problem 1. Consider partitioning an array a[] containing the following keys, by calling the partition() method (shown below) from quick sort, as partition(a, 0, a.length-1): PARTIONEXML private static int partition (Comparable []a, int lo, int hi) { int i = lo; int j = hi + 1; Comparable v = a[lo ]; while(true) { while(less(a[++i], v)) {if(i == hi) { break; } } while(less(v, a[--j ])) {if(j == lo) { break; } } if (i >= j) { break ; } exch (a, i, j); } exch (a, lo , j); return j; } Show steps and detail explanations for: (solutions are given) a.What is the value of the pivot element v? b.What is the value returned by the function call, ie, what is the destination index of the pivot? c.What is the state of the array after the call? Given solutions: a.P b.7 c.EALMIONPXTR
Problem 1. Consider partitioning an array a[] containing the following keys, by calling the partition() method (shown below) from quick sort, as partition(a, 0, a.length-1): PARTIONEXML
private static int partition (Comparable []a, int lo, int hi) { int i = lo;
int j = hi + 1;
Comparable v = a[lo ];
while(true) {
while(less(a[++i], v)) {if(i == hi) { break; } }
while(less(v, a[--j ])) {if(j == lo) { break; } }
if (i >= j) { break ; }
exch (a, i, j);
}
exch (a, lo , j);
return j;
}
Show steps and detail explanations for: (solutions are given)
a.What is the value of the pivot element v?
b.What is the value returned by the function call, ie, what is the destination index of the pivot?
c.What is the state of the array after the call?
Given solutions:
a.P
b.7
c.EALMIONPXTR
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images