Question: Question 1 1 p t s PARtition ( A , p , r ) x = A [ r ] , / / the pivot

Question 1
1pts
PARtition (A,p,r)
x=A[r],// the pivot
i=p-1,?? highest index into the low side
for j=p to r-1,?? process each element other than the pivot
,if A[j]x,?? does this element belong on the low side?
,,i=i+1,?? index of a new slot in the low side
,,exchange A[i] with A[j]// put this element there
exchange A[i+1] with A[r]// pivot goes just to the right of the low side
return i+1// new index of the pivot
partition.jpg
If you apply the PARTITION (A,1,12) algorithm on an array ,117,151,116,176,194,155, what value would be returned?
Please note that array A index is 1-based, meaning the first element has index 1.
Question 1 1 p t s PARtition ( A , p , r ) x = A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!