/*standard heapsort *template void heapsortvector forint size > -- /buildheap *percdownaia size)forint size -- std::swapa ]aj )/deletemax *percdowna )/*internal method for heapsort is the index of an item in the heap returns the index of the left child *inline int leftchildint return /*internal method for heapsort that is used in deletemax and buildheap is the position from which to percolate down is the logical size of the binary heap *template void percdownvector aint iint int childcomparable tmpfortmp std::moveai )leftchildi ni child child leftchildi )ifchild ! &achild achild ++childiftmp achild ai std::moveachild )else breakai std::movetmp )figure heapsort