Modify Insertion sorting algorithm so that it keeps track of thenumber of comparisons it performs and the number of exchanges(swaps) it performs during a single sorting operation. Keep trackof these numbers using two long integer counters; one to keep trackof the number of comparisons and another to keep track of thenumber of swaps
Algorithm for InsertionSort:
import java.util.Arrays;
import java.util.Random;
public class InsertionSort {
private int[] data;
private static final Random generator = new Random();
public InsertionSort( int size ) {
data = new int[ size ];
for ( int i = 0; i < size; i++ )
data[ i ] = 10 + generator.nextInt( 90 );
}
// call this method
PayPal Gateway not configured
PayPal Gateway not configured