Organize by order #26

Merged
cromer merged 2 commits from changeorder into master 2018-11-17 17:12:04 -03:00
2 changed files with 21 additions and 12 deletions

View File

@ -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);

View File

@ -19,7 +19,10 @@
* @param yp Segundo valor
*/
void swap(int *xp, int *yp) {
int temp = *xp;
*xp = *yp;
*yp = temp;
if (xp == yp) {
return;
}
*xp = *xp + *yp;
*yp = *xp - *yp;
*xp = *xp - *yp;
}