From 369f41c88684c7b5614143db6f9fdef47411f8a4 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sat, 17 Nov 2018 17:11:08 -0300 Subject: [PATCH] order the algorithms from worse to best --- src/sort.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/sort.c b/src/sort.c index 956e87b..d232a5c 100644 --- a/src/sort.c +++ b/src/sort.c @@ -325,36 +325,42 @@ int main (int argc, char **argv) { } } - if (merge) { - start_sort("Merge sort corriendo... ", n); - merge_sort(work_array, n); - end_sort(); - } - + // O(nlog(n)) if (quick) { start_sort("Quick sort corriendo... ", n); quick_sort(work_array, n); end_sort(); } - if (bubble) { - start_sort("Bubble sort corriendo... ", n); - bubble_sort(work_array, n); + // O(nlog(n)) + if (merge) { + start_sort("Merge sort corriendo... ", n); + merge_sort(work_array, n); end_sort(); } + // O(nlog2(n)) if (bitonic) { start_sort("Bitonic sort corriendo... ", n); bitonic_sort(work_array, n); end_sort(); } + // O(n+k) if (count) { start_sort("Count sort corriendo... ", n); count_sort(work_array, n); end_sort(); } + // O(n^2) + if (bubble) { + start_sort("Bubble sort corriendo... ", n); + bubble_sort(work_array, n); + end_sort(); + } + + // O(n^2) if (selection) { start_sort("Selection sort corriendo... ", n); selection_sort(work_array, n);