Question: 7 . Use Figure 5 . 3 as a template, illustrate the operation of HoarePartition ( A [ 1 , 6 ] ) on the

7. Use Figure 5.3 as a template, illustrate the operation of HoarePartition(A[1,6]) on the array A =4,9,5,10,3,6>. Show all intermediate steps how the array is transformed.
//Partitions a subarray by Hoares algorithm, using the first element
// as a pivot
//Input: Subarray of array A[0..n 1], defined by its left and right
// indices l and r (l r)
//Output: Partition of A[l..r], with the split position returned as
// this functions value p A[l] i l; j r +1
repeat
repeat i i +1 until A[i]>= p
repeat j j 1 until A[j ]= p
swap(A[i], A[j ]) until i >= j swap(A[i], A[j ])//undo last swap when i >= j
swap(A[l], A[j ])
return j9
(a)
 7. Use Figure 5.3 as a template, illustrate the operation of

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 Databases Questions!