Question: Write a program in your favorite language implementing the algorithm INSERTION SORT so that it counts the total number of comparisons for any input array,

Write a program in your favorite language implementing the algorithm INSERTION SORT so that it counts the total number of comparisons for any input array, and the average number of comparisons for a set of permutations of the said array. Use as input: (i) all permutations of <1,2,3,4>; (ii) all permutations of <1,2,3,4,5>; 50 random permutations of <1,2,...,20>

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!