[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Some sorting visualization are awesome

You are currently reading a thread in /g/ - Technology

Thread replies: 16
Thread images: 3
File: Sorting.jpg (510 KB, 1920x1080) Image search: [Google]
Sorting.jpg
510 KB, 1920x1080
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;
}
>>
>>51441556
fn Bogo(L)
while not sorted(L) do
shuffle(L)
od
end

Eventually, yes.
>>
>>51441592
Just pretend printarray is printarray(int *array)
>>
File: 1447791810408.jpg (107 KB, 1280x720) Image search: [Google]
1447791810408.jpg
107 KB, 1280x720
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.
>>
File: purdy.png (92 KB, 761x803) Image search: [Google]
purdy.png
92 KB, 761x803
>>51441655
>>
>>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
Thread replies: 16
Thread images: 3

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK