5 #ifndef DSALGLIB_HEAPSORT_H 6 #define DSALGLIB_HEAPSORT_H 12 template<
typename type>
17 long long int parent=(index-1)/2;
18 if(objs[parent]<objs[index])
20 swapit(objs[parent],objs[index]);
28 template<
typename type>
32 if(index>=0&&index<last)
34 long long int lc=2*index+1,rc=2*index+2,large;
43 if(objs[index]<objs[large])
45 swapit(objs[index],objs[large]);
53 template<
typename type>
56 long long int i,last = arr.
size(),done;
63 swapit(arr[0],arr[done-1]);
73 #endif //DSALGLIB_HEAPSORT_H
void _reheapup(array< type > objs, long long int index)
void _reheapdown(array< type > objs, long long index, long long int last)
void heapsort(array< type > arr)