Question
An inversion in a list of distinct integers (a1, . . . , an) is a pair ai, aj such that i < j and
An inversion in a list of distinct integers (a1, . . . , an) is a pair ai, aj such that i < j and ai > aj . Fnd the value of the biggest difference among inversion pairs. Example: for the sequence [11, 7, 1, 17, 4, 3, 6, 2, 13, 20, 15, 9], the greatest difference among all inversion pairs is 15 coming from the pair (17, 2).
Design a divide and conquer type algorithm in O(nlogn) runtime that uses mergesort and finds the value of the greatest difference between all inversion pairs in a list of distinct integers.
I think you can keep track of the max difference when you try to merge the two arrays in mergesort but i'm having trouble with the pseudocode.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started