Anonymous user
Sorting algorithms/Heapsort: Difference between revisions
→{{header|VBA}}: fix bugs
(→{{header|FreeBASIC}}: fix more bugs) |
(→{{header|VBA}}: fix bugs) |
||
Line 4,003:
Dim temp As Integer
While root * 2 + 1 <= eend
Dim child As Long : child = root * 2 + 1
If (child + 1 <= eend
If (list(lb + child)
child = child + 1
End If
End If
If list(lb + root) < list(lb + child) Then
Line 4,023 ⟶ 4,025:
Dim lb As Long : lb = LBound(list)
Dim count As Long : count = UBound(list) - lb + 1
Dim start As Long : start =
Dim eend As Long : eend = count - 1▼
While start >= 0
SiftDown list(), start,
start = start - 1
Wend
▲ Dim eend As Long : eend = count - 1
Dim temp As Integer
Line 4,038 ⟶ 4,040:
list(lb) = temp
SiftDown list(), 0, eend▼
eend = eend - 1
▲ SiftDown list(), 0, eend
Wend
End Sub</lang>
|