Anonymous user
Sorting algorithms/Heapsort: Difference between revisions
Replace translated implementation with native implementation of pseudocode from the introduction
Not a robot (talk | contribs) (Add PL/M) |
(Replace translated implementation with native implementation of pseudocode from the introduction) |
||
Line 2,718:
=={{header|Javascript}}==
<lang Javascript>
function
heapify(arr)
[arr[end], arr[0]] = [arr[0], arr[end]]
var end = arr.length - 1;▼
▲ swap(arr, 0, end);
▲ end -= 1
}
}
function
var i;▼
▲ sift_element_down_heap(arr, i, arr.length);
▲ i -= 1;
}
}
function
while (rootPos * 2
if (
}
}
test('rosettacode', () => {
arr = [12, 11, 15, 10, 9, 1, 2, 3, 13, 14, 4, 5, 6, 7, 8,]
expect(arr).toStrictEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
{{out}}
<pre>
|