Question: Problem 3. Consider the following Partition algorithm used by QuicKSORT (this version of Partition is based on the algorithm from the slides with the for-loop

 Problem 3. Consider the following Partition algorithm used by QuicKSORT (this

Problem 3. Consider the following Partition algorithm used by QuicKSORT (this version of Partition is based on the algorithm from the slides with the for-loop replaced by a while-loop). \begin{tabular}{l} \hline Algorithm PaRtition (L, start, end ) : \\ 1: v,i,j:=L[ start ], start, start +1. \\ 2: while j= end do \\ 3: if L[j]v then \\ 4:i:=i+1. \\ 5: Exchange L[i] and L[j]. \\ 6: end if \\ 7: j:=j+1. \\ 8: end while \\ 9: Exchange L[i] and L[ start ] \\ 10: return i. \end{tabular} P3.1. Illustrate the operations performed by Partition on the array A=[21,45,7,12,28,11,17]. Show the content of A after each execution of the loop body. P3.2. Provide pre-conditions and post-conditions for Partition and provide an invariant and bound function for the while-loop at Line 2. Prove the correctness of PaRTITION. P3.3. Argue how Partition can be adjusted to run on singly linked lists L, while keeping a running time of L

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!