Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python program - looking for help coding a merge sort with some specific criteri

ID: 3707789 • Letter: P

Question

Python program - looking for help coding a merge sort with some specific criteria

I need to implement a mergesort and keep track of execution times of varying inputs, (in nanosec, so if using time() function *1e+9)

the inputs should be read in from an input file, "input.txt" with a very large number of integers(~100000), output is a little funky, I need to first take the first 1000 numbers, perform a merge sort then return the exceution time, then call back to the original(unsorted) list take 2000 integers then sort them, then get the execution time, then 3000 and so on. then print the execution times, in a format I can easily paste into excel to create a graph.

I've been using

https://www.random.org/integers/?num=10000&min=1&max=10000000&col=5&base=10&format=html&rnd=new

to get a seed of random integers for it to work with.

I've got the merge sort program pretty much down, just need help figuring out how to set it up so it reads from the input.txt file and outputs the execution times and a copy-paste-able format. I can comment what I have for merge sort already if that would help.

Explanation / Answer


Hi. please find the answer above.. i have given comments so that it is easy for you to understand. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!