Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write both insertion sort and merge sort programs in Python and follow the instructions below to test the programs with all data sets provided below.

Write both insertion sort and merge sort programs in Python and follow the instructions below to test the programs with all data sets provided below. You may reuse any existing insertion and recursive merge sorting algorithms available out there without specifying the references.
2-1) Using your time efficiency function from HW1, Measure the execution times of both insertion and merge sorting algorithms using the 6 data files.
2-2) Count the total number of comparisons for the completion of each sorting algorithm.
Here are the set pdf data files you should use for your testing:
1,000,000 integers are in rand1000000.txt (the largest)
Download rand1000000.txt (the largest)
1,000 integers are in rand1000.txt
Download rand1000.txt (for the initial testing purpose)
Other data sets.
rand10000.txt
Download rand10000.txt
rand100000.txt
Download rand100000.txt
rand250000.txt
Download rand250000.txt
rand500000.txt
Download rand500000.txt
2-3) Record the execution time with each data size and display the results in a graph using any Python data visualization library. (matplotlib, plotly, ...).
NOTE 1: For counting the number of comparisons in a mergesort that employs recursive function calls, using a global variable might be more practical, and one of those cases where using a global variable makes more sense.
NOTE 2: Ensure you read the data as integers, not as strings.
NOTE 3: Ensure the second algorithm works with the initial unsorted dataset, not the result dataset sorted by the other algorithm.
NOTE 4: You may add the following lines to test all the data sizes in one test run
fileNames =["rand1000.txt", "rand10000.txt", "rand100000.txt", "rand250000.txt", "rand500000.txt", "rand1000000.txt"]
for name in fileNames :
[your codes ...]

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

More Books

Students also viewed these Databases questions

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago