Question: 2. Problem You have been asked to find the number of inversions in an array. An inversion is when a larger number appears before a



2. Problem You have been asked to find the number of inversions in an array. An inversion is when a larger number appears before a smaller number. In the follow example, there are 3 inversions 1. 3 before2 2. 3 before 1 3. 2 before 1 You need to write two different algorithms to solve this problem. One is "slow". It is the nave approach using nested loops. The "fast" approach uses a modified mergesort that counts the number of inversions and returns that count. Your program will always run the fast algorithm unless the user specifies "slow" as the (only) command-line argument. Here are some examples of how the program should run $. ./inversioncounter Enter sequence of integers, each followed by a space: x 1 2 3 Error: Non-integer value x' received at index 0 $. ./inversioncounter Enter sequence of integers, each followed by a space:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
