Question: Please complete in Python and show screenshots of all code and output Programming question (35 points): Let {a1, a2, a3,...an) be a permutation of {1,2,3,...n}

 Please complete in Python and show screenshots of all code and

Please complete in Python and show screenshots of all code and output

Programming question (35 points): Let {a1, a2, a3,...an) be a permutation of {1,2,3,...n} (ai, aj) is an inversion if i aj. Your task is to implement both the brute force method (O(n)) and the divide and conquer method (O(nlogn)) for counting the number of inversions for a given array A of size n, that contains permutation of {1,2,3,...n}. You are provided with 14 input files, the names are 10, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 1000, 5000, 10000. These files contain random permutation of {1,2,3,...n}. The filename represents the number of entries in each of the files. Use these as input for your program. Plot the running time of both the methods (brute force and divide and conquer) on these 14 datasets. Also, report the number of inversions in all the datasets. Note: If your brute-force technique starts taking too much time, then you can choose to abort running the brute-force approach for larger values of n. Programming question (35 points): Let {a1, a2, a3,...an) be a permutation of {1,2,3,...n} (ai, aj) is an inversion if i aj. Your task is to implement both the brute force method (O(n)) and the divide and conquer method (O(nlogn)) for counting the number of inversions for a given array A of size n, that contains permutation of {1,2,3,...n}. You are provided with 14 input files, the names are 10, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 1000, 5000, 10000. These files contain random permutation of {1,2,3,...n}. The filename represents the number of entries in each of the files. Use these as input for your program. Plot the running time of both the methods (brute force and divide and conquer) on these 14 datasets. Also, report the number of inversions in all the datasets. Note: If your brute-force technique starts taking too much time, then you can choose to abort running the brute-force approach for larger values of n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!