A test harness program for testing sorting methods is


In Exercise 1 you were asked to modify the Sor t s program so that it would output the number of swaps used by a sorting method. It is a little more difficult to have the program also output the number of comparisons needed. You must include one or more statements to increment your counter within the sorting methods themselves. For each of the listed methods, make and test the changes needed, and list the number of comparisons needed by Sor t s to sort an array of 50 random integers.

2143_1fc6ef7f-cb6e-4c65-8f41-547b35e77287.png

Exercise 1

A test harness program for testing sorting methods is provided with the rest of the textbook program files. It is in the file Sor t s . j a va in the c h10 package. The program includes a s wa p method that is used by all of the sorting methods to swap array elements.

a. Describe an approach to modifying the program so that after calling a sorting method the program prints out the number of swaps needed by the sorting method.

b. Implement your approach.

c. Test your new program by running the s e l e c t i onSor t method. Your program should report 49 swaps

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: A test harness program for testing sorting methods is
Reference No:- TGS01623298

Expected delivery within 24 Hours