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 @@
|
|||
fcn cocktailSort(a){
|
||||
swapped,begin,end:=False,-1,a.len() - 2;
|
||||
do{
|
||||
swapped,begin=False,begin + 1;
|
||||
foreach i in ([begin .. end]){
|
||||
if(a[i]>a[i+1]){ a.swap(i,i+1); swapped=True; }
|
||||
}
|
||||
if(not swapped) break;
|
||||
swapped,end=False,end - 1;
|
||||
foreach i in ([end..begin,-1]){
|
||||
if(a[i]>a[i+1]){ a.swap(i,i+1); swapped=True; }
|
||||
}
|
||||
}while(swapped);
|
||||
a
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
cocktailSort(List(2,1)).println();
|
||||
x:=List(5, -1, 101, -4, 0, 1, 8, 6, 2, 3 );
|
||||
cocktailSort(x).println();
|
||||
x="the lazy fox jumped over the brown dog".split(" ").copy();
|
||||
cocktailSort(x).println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue