QUESTION AND ANSWER FOR Q3 :
- Write the state of the elements of the following array aftereach pass of the outmost loop of the selectionsort algorithm has occurred (after each element isselected and moved into place)
Int[] n1 = {63, 9,45, 72, 27, 18, 54, 36}
ANS:
Trace of selection sort:9 63 45 72 27 18 54 36 9 18 45 72 27 63 54 36 9 18 27 72 45 63 54 36 9 18 27 36 45 63 54 72 9 18 27 36 45 63 54 72 9 18 27 36 45 54 63 72 9 18 27 36 45 54 63 72
PLEASE ANSWER Q4 BELOW:
- Using the same array from Q3 above, trace the completeexecution of the merge sort algorithm. Show thesubarrays that are created by the algorithm and show the merging ofsubarrays in the larger sorted array.
Int[] n1 = {63, 9,45, 72, 27, 18, 54, 36}
Expert Answer
Answer to QUESTION AND ANSWER FOR Q3 : Write the state of the elements of the following array after each pass of the outmost loop …