lol bubble sort
use a real sorting algorithm, like the
FIBONACCIBUTTSORT
Name:
Anonymous2013-10-11 15:20
home from school again!!!
[bold]/prog/ is about to become awesome[/bold]
Name:
Anonymous2013-10-11 20:38
I finally completed my sorting algorithm! bubblesort went over my head so I decided to implement a different algo
a = [1, 2, 3, 4, 5]
while a != sorted(a):
import random
random.shuffle(a)
print(a)
My curfew is coming up so I must go
Name:
Anonymous2013-10-12 15:04
iM BACK MOTHERFUCKERS!
dID YOU MISS ME?
Name:
Anonymous2013-10-12 15:04
I'm back motherfuckers!
Did you miss me?
Name:
Anonymous2013-10-12 15:20
fun fact: bubblesort is exactly twice as fast as randomly swapping two random elements that are out of order until the array is sorted (is there a name for that kind of sort?)
Name:
Anonymous2013-10-12 17:40
>>5
>while a != sorted(a):
so you sort it in order to sort it? top lols
>>8
there must be, else how would they refer to it when they presented you this fact? btw where did you see it?
I tried coding it
function sort(x){
while (!issorted(x)){
var a1 = R(x.length);
var a2 = R(x.length);
if((a1<a2 && x[a1]>x[a2])||(a1>a2 && x[a1]<x[a2])){
var temp=x[a1];
x[a1]=x[a2];
x[a2]=temp;
}
}
}
>>9
I came up with it myself. Tested it against bubblesort and figured out that on average, bubblesort is twice as efficient.
Name:
122013-10-12 19:54
And by bubblesort I mean any sort that reorders two immediately following elements in whatever order (random, cocktail sort, etc), they're all the same for big arrays: O(N^2). So my anus-sort, as I will call it if there's no name for it, is O(2N^2).