Question: 7 . Use Figure 5 . 3 as a template, illustrate the operation of HoarePartition ( A [ 1 , 6 ] ) on the
Use Figure as a template, illustrate the operation of HoarePartitionA on the array A 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 An defined by its left and right
indices l and r l r
Output: Partition of Alr with the split position returned as
this functions value p Al i l; j r
repeat
repeat i i until Ai p
repeat j j until Aj p
swapAi Aj until i j swapAi Aj undo last swap when i j
swapAl Aj
return j
a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
