Chapter 7: Problem 10
Give the transpose of the permutation \([2,5,1,6,3,4],\) and find the number of inversions in both permutations. What is the total number of inversions?
Chapter 7: Problem 10
Give the transpose of the permutation \([2,5,1,6,3,4],\) and find the number of inversions in both permutations. What is the total number of inversions?
All the tools & learning materials you need for study success - in one app.
Get started for freeWrite an algorithm that sorts a list of \(n\) elements in nonincreasing order by finding the largest and smallest elements and exchanges those elements with the elements in the first and last positions. Then the size of the list is reduced by \(2,\) excluding the two elements that are already in the proper positions, and the process is repeated on the remaining part of the list until the entire list is sorted. Analyze your algorithm and show the results using order notation.
In the process of rebuilding the master list, the Radix Sort algorithm (Algorithm 7.6) wastes a lot of time examining empty sublists when the number of piles (radix) is large. Is it possible to check only the sublists that are not empty?
Show that the permutation \([n, n-1, \ldots, 2,1]\) has \(n(n-1)\) inversions.
Suppose we have a very large list stored in external memory that needs to be sorted. Assuming that this list is too large for internal memory, what major factor(s) should be considered in designing an external sorting algorithm?
Show that the worst-case and average-case time complexities for the number of assignments of records performed by the Insertion Sort algorithm (Algorithm 7.1) are given by $$W(n)=\frac{(n+4)(n-1)}{2} \approx \frac{n^{2}}{2} \quad \text { and } \quad A(n)=\frac{n(n+7)}{4}-1 \approx \frac{n^{2}}{4}$$
What do you think about this solution?
We value your feedback to improve our textbook solutions.