Homework Solution: Inversions. Let A[1, … n] be an array of n distinct numbers. If i A[j], then the pair (i, j) is called an inversion…

    2. Inversions. Let A[I...] be an array of n distinct numbers. If i < j and Ali] > AU], then the pair (i,j) is called an inversion of A (a) List the five inversions of the array < 2,3,8,6,1> (b) What array with elements from the set {1,2,...,n} has the most number of inversions? How many does it have? in the input array? Justify your answer. O(n log n) worst-case running time (c) What is the relationship between the running time of insertion sort and the number of inversions d) Give an algorithm that determines the number of inversions in any permutation of n elements in (Hint: Modify Merge-sort.)
    Inversions. Let A[1, ... n] be an array of n distinct numbers. If i A[j], then the pair (i, j) is called an inversion of A. (a) List the five inversions of the array . (b) What array with elements from the set {1, 2, ..., n} has the most number of inversions? How many does it have? (c) What is the relationship between the running time of insertion sort and the number of inversions in the input array? Justify your answer. d) Give an algorithm that determines the number of inversions in any permutation of n elements in O(n log n) worst-case running time.

    Expert Answer

    2. Deflections. Let A[I...] be an deck of n dissimilar total. If i < j and Ali] > AU], then the brace (i,j) is determined an deflection of A (a) List the five deflections of the deck < 2,3,8,6,1> (b) What deck with elements from the be {1,2,...,n} has the most enumerate of deflections? How manifold does it bear? in the input deck? Justify your confutation. O(n log n) worst-case vulgar span (c) What is the correlativeness among the vulgar span of augmentation character and the enumerate of deflections d) Give an algorithm that determines the enumerate of deflections in any transposition of n elements in (Hint: Modify Merge-sort.)

    Inversions. Let A[1, … n] be an deck of n dissimilar total. If i A[j], then the brace (i, j) is determined an deflection of A. (a) List the five deflections of the deck . (b) What deck with elements from the be {1, 2, …, n} has the most enumerate of deflections? How manifold does it bear? (c) What is the correlativeness among the vulgar span of augmentation character and the enumerate of deflections in the input deck? Justify your confutation. d) Give an algorithm that determines the enumerate of deflections in any transposition of n elements in O(n log n) worst-case vulgar span.

    Expert Confutation