Create three identical arrays with 5000 random integers in the range of 1-100. Implement 3 different sorts on the arrays, O(n2), O(n log n), O(n).
Implement a separate counter for each sort. Start each counter at zero and increment the counter inside loops of the associated sort. For example, in the O(n2) loop, increment the counter inside the inner loop. For sorts that have more than one loop, increment the counter inside each loop. For recursive sorts, add an additional reference parameter for the counter.
Use a system clock timer to start the time immediately before each sort and end immediately after each sort. If you don't know how to do this, Google is your friend. If you still have trouble with implementation, see me.
Average time and counter results over 10 runs, using a different random seed for each run. An easy way to do this is to use the loop control variable as the random seed.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.