Sorting algorithms/Heapsort: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed subroutine names (which signifies ownership).) |
|||
Line 3,207: | Line 3,207: | ||
<pre>[0,0,2,3,3,8,17,36,40,72]</pre> |
<pre>[0,0,2,3,3,8,17,36,40,72]</pre> |
||
=={{header|Mathematica}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
<lang Mathematica>siftDown[list_,root_,theEnd_]:= |
<lang Mathematica>siftDown[list_,root_,theEnd_]:= |
||
While[(root*2) <= theEnd, |
While[(root*2) <= theEnd, |
||
Line 3,217: | Line 3,217: | ||
] |
] |
||
] |
] |
||
heapSort[list_] := Module[{ count, start}, |
heapSort[list_] := Module[{ count, start}, |
||
count = Length[list]; start = Floor[count/2]; |
count = Length[list]; start = Floor[count/2]; |