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