Question: 4. (7 points) The PARTITION(A, p,r) procedure returns an index q such that each element of Alp..q 1 is less than or equal to Aa)

4. (7 points) The PARTITION(A, p,r) procedure returns an index q such that each element of Alp..q 1 is less than or equal to Aa) and each element of Alg 1..r is greater than A. Modify the PARTITION procedure to produce a procedure PARTITION' (A,p,r), which permutes the elements of Alp..r] and returns two indices q and t, where p S q tS r, such that all elements of Alg..t are equal, . each element of Alp..q is less than A, and . each element of Alt 1..r] is greater than Aa Like PARTITION, your PARTITION' procedure should take (r-p) time. Explain briefly how your PARTITION' (A, p,r) works
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
