Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
quickSort(v)={
|
||||
if(#v<2, return(v));
|
||||
my(less=List(),more=List(),same=List(),pivot);
|
||||
pivot=median([v[random(#v)+1],v[random(#v)+1],v[random(#v)+1]]); \\ Middle-of-three
|
||||
for(i=1,#v,
|
||||
if(v[i]<pivot,
|
||||
listput(less, v[i]),
|
||||
if(v[i]==pivot, listput(same, v[i]), listput(more, v[i]))
|
||||
)
|
||||
);
|
||||
concat(quickSort(Vec(less)), concat(Vec(same), quickSort(Vec(more))))
|
||||
};
|
||||
median(v)={
|
||||
vecsort(v)[#v>>1]
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue