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

Some sorting visualization are awesome

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 16
Thread images: 3

File: Sorting.jpg (510KB, 1920x1080px) Image search: [iqdb] [SauceNao] [Google]
Sorting.jpg
510KB, 1920x1080px
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 (107KB, 1280x720px) Image search: [iqdb] [SauceNao] [Google]
1447791810408.jpg
107KB, 1280x720px
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 (92KB, 761x803px) Image search: [iqdb] [SauceNao] [Google]
purdy.png
92KB, 761x803px
>>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 posts: 16
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.