文件名称:几种排序算法的比较(java代码)
文件大小:5KB
文件格式:RAR
更新时间:2016-07-11 01:59:36
数据结构排序
import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class SortTest { public static void main(String[] args)throws Exception { String[] strs2=new String[]{"希尔排序","直接插入排序","折半插入排序","冒泡排序"}; new SortTest().test(strs2,100000,1900000,100000); } private void testErr(String[] strings) throws Exception{ //System.out.println(Arrays.toString(old)); System.out.println(Arrays.toString(strings)); Number[] old=getRundom(50); Integer[] oo={1,2,3,3,2,21,5,6,7,78,5,65,8,7,6,6,6,6,6,9,56544,354,32,4,456,8,89,-9,0,3,243,-321,321,-3,-2,21}; old=oo; for(String s:strings){ Number[] testNum=Arrays.copyOf(old, old.length); long begin=System.currentTimeMillis(); SortTest.class.getMethod(s, Number[].class).invoke(this, (Object)testNum); long end=System.currentTimeMillis(); System.out.println(s+":"+(end-begin)+"\t"); System.out.println(Arrays.toString(testNum)); } System.out.println(); }
【文件预览】:
排序比较
----.project(388B)
----src()
--------SortTest.java(5KB)
----.settings()
--------org.eclipse.jdt.core.prefs(598B)
----.classpath(301B)
----bin()
--------SortTest.class(5KB)