Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q.1. (50 Points) Sort A = [ 13, 6, 30, 1, 5, 9, 12, 6, 5, 3, 5, 17] using quicks

ID: 3740265 • Letter: Q

Question

Q.1. (50 Points) Sort A = [ 13, 6, 30, 1, 5, 9, 12, 6, 5, 3, 5, 17] using quicksort with median-of-three partitioning (Figure 7.16 from your textbook) and a cutoff of 3. For this question, you need to illustrate the step by step solution of the quick sort algorithm as illustrated in your textbook Fig 7.14. Please strictly follow the steps of the partitioning and quick sort algorithm.

Q.2. (50 Points) Sort array A = [ 13, 6, 30, 1, 5, 9, 12, 6, 5, 3, 5,17] using merge sort and illustrate your recursion calls it is shown in your lecture notes (sorting.pdf)

Q.3. (10 Bonus Points) Sort the array A = [ 3, 1, 4, 1, 5, 9, 2, 6, 5] using insertion sort and illustrate your solution it is shown in your lecture notes (sorting.pdf)

Explanation / Answer

1

ALGORITHM STEPS OF QUICK SHORT STEPS:

Step 1 ?

Choose the maximum index value has pivot

Step 2 ?

take two variables to point left and correct of the list excluding.

Step 3 ?

left point to the low directory.

Step 4 ?

right point to the far above the ground

Step 5 ?

while value at left is fewer than pivot go right

Step 6 ?

while value at correct is greater than pivot go left

Step 7 ?

if both step 5 plus step 6 does not match exchange left and right

Step 8 ?

if left ?

right,

the point wherever they met is novel pivotQUICH SHORT ALGORITHM :-?

QuickSort (a , p , r )

x leftarrow a [ p ]

i leftarrow p – 1

j leftarrow r + 1

while true

do REPEAT j leftarrow j- 1

until a [ j ] leqslant x

do repeat i leftarrow i + 1

until a [ i ] geq x

if i < j

then exchange a [ i ] leftrightarrow a [ j ]

?

?