-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatistics.cpp
More file actions
28 lines (24 loc) · 972 Bytes
/
Statistics.cpp
File metadata and controls
28 lines (24 loc) · 972 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
25
26
27
28
#include "Statistics.h"
void Statistics::startTimer() {
startTime = high_resolution_clock::now();
}
void Statistics::stopTimer() {
endTime = high_resolution_clock::now();
}
double Statistics::getExecutionTime() const {
duration<double> executionTime = duration_cast<duration<double>>(endTime - startTime);
return executionTime.count();
}
string Statistics::getComplexity(const string& algorithm) const {
if (algorithm == "BubbleSort") {
return "Complejidad Temporal: O(n^2)\nComplejidad Espacial: O(1)";
} else if (algorithm == "QuickSort") {
return "Complejidad Temporal: O(n log n) en promedio\nComplejidad Espacial: O(log n)";
} else if (algorithm == "MergeSort") {
return "Complejidad Temporal: O(n log n)\nComplejidad Espacial: O(n)";
} else if (algorithm == "BinarySearch") {
return "Complejidad Temporal: O(log n)\nComplejidad Espacial: O(1)";
}
// Añadir más algoritmos
return "";
}