Sorting algorithms/Heapsort: Difference between revisions

m
→‎{{header|C}}: use for loops instead of while statements.
(Added C)
m (→‎{{header|C}}: use for loops instead of while statements.)
Line 142:
int start, end;
/* heapify */
start = (count-2)/2;
 
whilefor (start >= (count-2)/2; start >=0; start--) {
siftDown( a, start, count);
start -= 1;
}
endfor (end= count-1; end > 0; end--) {
while (end > 0) {
SWAP(a[end],a[0]);
siftDown(a, 0, end);
end -= 1;
}
}
Line 182 ⟶ 178:
-18.0, 88.1, 30.44, -37.2, 3012.0, 49.2};
#define VSIZE (sizeof(valsToSort)/sizeof(valsToSort[0]))
 
heapsort(valsToSort, VSIZE);
printf("{");
Anonymous user