-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathMain4.java
More file actions
24 lines (19 loc) · 702 Bytes
/
Main4.java
File metadata and controls
24 lines (19 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* Created by liuyubobobo.
*/
public class Main4 {
public static void main(String[] args) {
// 数据规模倍乘测试mergeSort
// O(nlogn)
System.out.println("Test for Merge Sort:");
for( int i = 10 ; i <= 26 ; i ++ ){
int n = (int)Math.pow(2,i);
Integer[] arr = MyUtil.generateRandomArray(n, 0, 1<<30);
long startTime = System.currentTimeMillis();
MyAlgorithmTester.mergeSort(arr, n);
long endTime = System.currentTimeMillis();
System.out.print("data size 2^" + i + " = " + n + "\t");
System.out.println("Time cost: " + (endTime - startTime) + " s");
}
}
}