-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighArrayApp.java
More file actions
57 lines (47 loc) · 1.31 KB
/
Copy pathHighArrayApp.java
File metadata and controls
57 lines (47 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.time.Duration;
import java.time.Instant;
import java.util.function.Consumer;
import java.util.function.Function;
public class HighArrayApp {
public static void main(String[] args) {
HighArray ha = new HighArray(20);
ha.insert(10);
ha.insert(20);
ha.insert(13);
ha.insert(21);
ha.insert(98);
ha.insert(74);
//ha.display();
ha.removeMax();
ha.delete(10);
ha.delete(21);
ha.delete(74);
//ha.display();
ha.insert(20);
ha.insert(84);
ha.insert(13);
ha.insert(90);
ha.insert(13);
ha.display();
ha.insertionSortAndRemoveDups();
ha.display();
//displaySortTimes(HighArray::insertionSort);
// displaySortTimes(HighArray::selectionSort);
// displaySortTimes(HighArray::bubbleSort);
//ha.removeDupsSorted();
//ha.display();
//System.out.print(ha.median());
}
public static void displaySortTimes(Consumer<HighArray>
sortingAlgorithm) {
HighArray ha = new HighArray(1000000);
for (int j = 0; j < 500000; j++) {
//long n = (long)(java.lang.Math.random()*(100000 - 1));
ha.insert(j);
}
Instant start = Instant.now();
sortingAlgorithm.accept(ha);
Instant end = Instant.now();
System.out.println(Duration.between(start,end).toMillis());
}
}