Reference no: EM132080081
Need help with sorting in java
Directions
Problem 1: Write (using pen-and-paper rather than code) the list after each pass of quick and merge sort for the following list of numbers. Assume that you are sorting the numbers into ascending order. For quick sort, assume that the first number from the sublist is chosen as the pivot. 54 17 21 18 4 7 19 41
Problem 2: Write the list after each pass of the quick sort algorithm for the following list of numbers, using the following pivot selection strategies: first value of the sublist, middle (not median) value of the sublist, and the median of the first, middle, and last values.
Assume you are sorting the numbers into ascending order. For example, in the first pass of the algorithm on these numbers, the first pivot selection strategy chooses 54, the middle strategy chooses 18 (because 18 and 4 are in the middle of the list; when the list is of even length, we can just choose to go with the first of the two middle values), and the median of the first, last and middle values chooses 41 as the pivot value, because 41 is the median of 54, 18 and 41. 54 17 21 18 4 7 19 41 Repeat the above for this list of numbers. Remember that you are sorting into ascending order.
92 47 29 22 21 20 16 14