算法(第四版)排序比较(插入排序和选择排序)

package suanfa;

import com.algs4.stdlib.StdOut;
import com.algs4.stdlib.StdRandom;
import com.algs4.stdlib.Stopwatch;

/**
 * Created by evan on 16/11/2.
 */
public class SortCompare {

    public static double time(String alg,Comparable[] sortList){
        Stopwatch timer = new Stopwatch();
        if(alg.equals("Insert")){
            InsertSorting.sort(sortList);
        }
        if(alg.equals("Select")){
            Selection.sort(sortList);
        }

        return timer.elapsedTime();
    }

    public static double timeRandomInput(String alg,int T,int N){

        double total = 0.0;
        for (int i=0;i

你可能感兴趣的:(算法(第四版)排序比较(插入排序和选择排序))