Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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}

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions