Anonymous user
Sorting algorithms/Heapsort: Difference between revisions
→{{header|FreeBASIC}}: fix more bugs
(Added VBA) |
(→{{header|FreeBASIC}}: fix more bugs) |
||
Line 1,553:
Dim As Long lb = LBound(hs)
While root * 2 + 1 <= end_
Dim As ULong child = root * 2 + 1
If (child + 1 <= end_)
child = child + 1
End If
Line 1,570:
Dim As Long lb = LBound(hs)
Dim As ULong count = UBound(hs) - lb + 1
Dim As Long start =
Dim As ULong end_ = count - 1▼
While start >= 0
siftdown(hs(), start,
start = start - 1
Wend
▲ Dim As ULong end_ = count - 1
While end_ > 0
Swap hs(lb + end_), hs(lb)
siftdown(hs(), 0, end_)▼
end_ = end_ - 1
▲ siftdown(hs(), 0, end_)
Wend
End Sub
|