-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathMain2.java
More file actions
24 lines (19 loc) · 717 Bytes
/
Main2.java
File metadata and controls
24 lines (19 loc) · 717 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 Main2 {
public static void main(String[] args) {
// 数据规模倍乘测试selectionSort
// O(n^2)
System.out.println("Test for Selection Sort:");
for( int i = 10 ; i <= 16 ; i ++ ){
int n = (int)Math.pow(2,i);
Integer[] arr = MyUtil.generateRandomArray(n, 0, 100000000);
long startTime = System.currentTimeMillis();
MyAlgorithmTester.selectionSort(arr, n);
long endTime = System.currentTimeMillis();
System.out.print("data size 2^" + i + " = " + n + "\t");
System.out.println("Time cost: " + (endTime - startTime) + " ms");
}
}
}