all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,18 @@
|
|||
var countSort = function(arr, min, max) {
|
||||
var i, z = 0, count = [];
|
||||
|
||||
for (i = min; i <= max; i++) {
|
||||
count[i] = 0;
|
||||
}
|
||||
|
||||
for (i=0; i < arr.length; i++) {
|
||||
count[arr[i]]++;
|
||||
}
|
||||
|
||||
for (i = min; i <= max; i++) {
|
||||
while (count[i]-- > 0) {
|
||||
arr[z++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// Line breaks are in HTML
|
||||
|
||||
var i, ages = [];
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
ages.push(Math.floor(Math.random() * (141)));
|
||||
}
|
||||
|
||||
countSort(ages, 0, 140);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
document.write(ages[i] + "<br />");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue