Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,23 @@
fn countingSort arr =
(
if arr.count < 2 do return arr
local minVal = amin arr
local maxVal = amax arr
local count = for i in 1 to (maxVal-minVal+1) collect 0
for i in arr do
(
count[i-minVal+1] = count[i-minVal+1] + 1
)
local z = 1
for i = minVal to maxVal do
(
while (count[i-minVal+1]>0) do
(
arr[z] = i
z += 1
count[i-minVal+1] = count[i-minVal+1] - 1
)
)
return arr
)

View file

@ -0,0 +1,4 @@
a = for i in 1 to 15 collect random 1 30
#(7, 1, 6, 16, 27, 11, 24, 16, 25, 11, 22, 7, 28, 15, 17)
countingSort a
#(1, 6, 7, 7, 11, 11, 15, 16, 16, 17, 22, 24, 25, 27, 28)