I’m trying to learn for my Java class and I’m stuck. Can you help?
Modify the Insertion Sort program from the book’s jar file, to determine the distance traveled of the cards during the Sort. The distance is how many positions were bypassed during the move of the Pivot card. Then write a driver program that randomly populates a list of 7 with numbers from 1 up to and including 13. The driver program should randomly generate 1000 lists (of 7) and calculate the distance. Find the average distance, and the minimum and maximum. Next see if you can say something about the first or last card, such as when the distance is high the first card is in the middle of the 1-13 range. Have your program prove your hypothesis.


0 comments