September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1,21 @@
Option Base 1
Private Function countingSort(array_ As Variant, mina As Long, maxa As Long) As Variant
Dim count() As Integer
ReDim count(maxa - mina + 1)
For i = 1 To UBound(array_)
count(array_(i) - mina + 1) = count(array_(i) - mina + 1) + 1
Next i
Dim z As Integer: z = 1
For i = mina To maxa
For j = 1 To count(i - mina + 1)
array_(z) = i
z = z + 1
Next j
Next i
countingSort = array_
End Function
Public Sub main()
s = [{5, 3, 1, 7, 4, 1, 1, 20}]
Debug.Print Join(countingSort(s, WorksheetFunction.Min(s), WorksheetFunction.Max(s)), ", ")
End Sub