Sort the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5 using insertion sort
Read moreTextbook Solutions for Data Structures and Algorithm Analysis in Java
Question
Suppose we implement the median of three routine as follows: Find the median ofa[left], a[center], a[right], and swap it with a[right]. Proceed with the normalpartitioning step starting i at left and j at right-1 (instead of left+1 and right-2).a. Suppose the input is 2, 3, 4, ... ,N 1,N, 1. For this input, what is the runningtime of this version of quicksort?b. Suppose the input is in reverse order. For this input, what is the running timeof this version of quicksort?
Solution
The first step in solving 7 problem number 51 trying to solve the problem we have to refer to the textbook question: Suppose we implement the median of three routine as follows: Find the median ofa[left], a[center], a[right], and swap it with a[right]. Proceed with the normalpartitioning step starting i at left and j at right-1 (instead of left+1 and right-2).a. Suppose the input is 2, 3, 4, ... ,N 1,N, 1. For this input, what is the runningtime of this version of quicksort?b. Suppose the input is in reverse order. For this input, what is the running timeof this version of quicksort?
From the textbook chapter Sorting you will find a few key concepts needed to solve this.
Visible to paid subscribers only
Step 3 of 7)Visible to paid subscribers only
full solution