Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
fcn circleSort(list){
|
||||
csort:=fcn(list,lo,hi,swaps){
|
||||
if(lo==hi) return(swaps);
|
||||
high,low,mid:=hi,lo,(hi-lo)/2;
|
||||
while(lo<hi){
|
||||
if(list[lo]>list[hi]){
|
||||
list.swap(lo,hi);
|
||||
swaps+=1;
|
||||
}
|
||||
lo+=1; hi-=1;
|
||||
}
|
||||
if(lo==hi)
|
||||
if (list[lo]>list[hi+1]){
|
||||
list.swap(lo,hi+1);
|
||||
swaps+=1;
|
||||
}
|
||||
swaps=self.fcn(list,low,low + mid,swaps);
|
||||
swaps=self.fcn(list,low + mid + 1,high,swaps);
|
||||
return(swaps);
|
||||
};
|
||||
list.println();
|
||||
while(csort(list,0,list.len()-1,0)){ list.println() }
|
||||
list
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
circleSort(L(6,7,8,9,2,5,3,4,1));
|
||||
circleSort(L(5,-1,101,-4,0,1,8,6,2,3));
|
||||
Loading…
Add table
Add a link
Reference in a new issue