-
Notifications
You must be signed in to change notification settings - Fork 0
/
outputData.java
127 lines (85 loc) · 3.08 KB
/
outputData.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Brett Waugh
* 3 December 2019
* outputData.java
* Runs each algorithm and displays the results.
* There is an option to uncomment some lines to
* see the results of each algorithm.
*/
public class outputData {
static void writeDat(int data[], linked li, Heap theHeap, int max) {
// Duplicate data for different sorting algorithms.
int[] data_b = data.clone();
int[] data_s = data.clone();
int[] data_i = data.clone();
int[] data_q = data.clone();
/****************************/
/* Beginning of Bubble Sort */
/****************************/
int start_b = getTime.time();
BubbleSort.sort(data_b);
int end_b = getTime.time();
int time_b = end_b - start_b;
// Troubleshooting, displays to console.
// System.out.println("Bubble Sort: ");
// BubbleSort.display(max, data_b);
System.out.println("Bubble Sort : " + time_b + " milliseconds.");
/****************************/
/* Beginning of Insert Sort */
/****************************/
int start_i = getTime.time();
insertSort.sort(data_i);
int end_i = getTime.time();
int time_i = end_i - start_i;
// Troubleshooting, displays to console.
// System.out.println("Insert Sort: ");
// insertSort.display(max, data_i);
System.out.println("Insertion Sort : " + time_i + " milliseconds.");
/*******************************/
/* Beginning of Selection Sort */
/*******************************/
int start_s = getTime.time();
selectSort.sort(data_s, max);
int end_s = getTime.time();
int time_s = end_s - start_s;
// Troubleshooting, displays to console.
// System.out.println("Selection Sort: ");
// selectSort.display(data_s, max);
System.out.println("Selection Sort : " + time_s + " milliseconds.");
/**************************/
/* Beginning of Heap Sort */
/**************************/
int start_h = getTime.time();
Heap.heapCall(max, theHeap);
int end_h = getTime.time();
int time_h = end_h - start_h;
// Troubleshooting, displays to console.
// System.out.println("Heap Sort: ");
// Heap.display(max);
System.out.println("Heap Sort : " + time_h + " milliseconds.");
/***************************/
/* Beginning of Merge Sort */
/***************************/
int start_m = getTime.time();
li.head = li.mergSort(li.head);
int end_m = getTime.time();
int time_m = end_m - start_m;
// Troubleshooting, displays to console.
// System.out.println("Merge Sort: ");
// linked.display(li);
System.out.println("Merge sort : " + time_m + " milliseconds.");
/**************************************************/
/* Beginning of Quicksort, median-of-three method */
/**************************************************/
// Partitions for quicksort should be of no more than two.
int partSize = 2;
int start_q = getTime.time();
quickSort.quickSortCall(max, data_q, partSize);
int end_q = getTime.time();
int time_q = end_q - start_q;
// Troubleshooting, displays to console.
// System.out.println("Quicksort: ");
// quickSort.display(max, data_q);
System.out.println("Quicksort : " + time_q + " milliseconds.");
}
}