Some sorting visualization are awesome
https://youtu.be/kPRA0W1kECg
https://youtu.be/ZZuD6iUe3Pc
>Bitonic sort
What the fuck did i just watch.
>>51441061
indeed, wtf
>not using sleep sort
>>51441061
>>51441262
>Bogo sort
so uh.. was anything supposed to come of that?
>>51441556
Here, have a christmas bogosort!#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define ARRMAX 9
int check (int *array) {
for (int i=0; i<ARRMAX-1; i++)
if (array[i] < array[i+1]) return 0;
return 1;
}
void printarray (int array[ARRMAX]) {
for (int i=0; i<ARRMAX; i++) {
int color_chance = rand() % 5;
char color_string[5];
switch (color_chance) {
case 0:
strcpy(color_string, "\033[32m"); break;
case 1:
strcpy(color_string, "\033[31m"); break;
default:
strcpy(color_string, "\033[0m");
}
printf("%s%02X%s ", color_string, array[i], "\033[0m");
}
putchar(10);
}
int main (void) {
int sorted = 0;
int unsorted[ARRMAX];
srand(time(NULL));
for (int i=0; i<ARRMAX; i++) {
unsorted[i] = rand() % 100;
}
while (!sorted) {
for (int i=0; i<ARRMAX; i++) {
int choice = rand() % ARRMAX;
int temp = unsorted[choice];
unsorted[choice] = unsorted[i];
unsorted[i] = temp;
}
printarray(unsorted);
sorted = check(unsorted);
}
puts("SORTED!");
printarray(unsorted);
return 0;
}
>>51441556fn Bogo(L)
while not sorted(L) do
shuffle(L)
od
end
Eventually, yes.
>>51441592
Just pretend printarray is printarray(int *array)
Which sorting algorithm for a large array of mostly-random numbers (file sizes and dates) is better than Quick Sort?
>>51441603
So a basic analogy would be just shuffling a deck of cards over and over completely until the cards are in order? Shit, I'd love to see that.
>>51441655
It's not exactly a sorting algorithm for busy people.
>>51441642
any sort of pigeonhole sort is pretty neat for running in pseudo O(n) time. some might even be better than quick sort if you tweak it to fit your dataset nicely.
http://www.sorting-algorithms.com/
>>51441061
>tfw no qt314 to make me a gintonic sort
>>51441642
Radix maybe depending on the data