Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
function stoogeSort (array, i, j) {
|
||||
if (j === undefined) {
|
||||
j = array.length - 1;
|
||||
}
|
||||
|
||||
if (i === undefined) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
if (array[j] < array[i]) {
|
||||
var aux = array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = aux;
|
||||
}
|
||||
|
||||
if (j - i > 1) {
|
||||
var t = Math.floor((j - i + 1) / 3);
|
||||
stoogeSort(array, i, j-t);
|
||||
stoogeSort(array, i+t, j);
|
||||
stoogeSort(array, i, j-t);
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
arr = [9,1,3,10,13,4,2];
|
||||
stoogeSort(arr);
|
||||
console.log(arr);
|
||||
Loading…
Add table
Add a link
Reference in a new issue