void sortHeap(DynArr *heap, comparator compare) { int i; _buildHeap(heap, compare); for(i= sizeDynArr(heap)-1; i>0; i--){ swapDynArr(heap,0,i); _adjustHeap(heap,i,0,compare); } }
void sortHeap(DynArr *heap) { _buildHeap(heap); int i; for(i=sizeDynArr(heap)-1; i>0; --i) { swapDynArr(heap, i, 0); _adjustHeap(heap, i, 0); } }
void sortHeap(DynArr *heap) { int maxpos; _buildHeap(heap); for(maxpos = heap->size - 1; maxpos >= 0; maxpos--){ swapDynArr(heap, maxpos, 0); _adjustHeap(heap, maxpos - 1, 0); } }
void sortHeap(DynArr *heap) { _buildHeap(heap); int last = heap->size - 1; while (last > 0) { swapDynArr(heap, 0, last); _adjustHeap(heap, last, 0); last--; } }
void sortHeap(DynArr *heap) { /* FIXME */ _buildHeap(heap); for(int i=sizeDynArr(heap)-1; i>0; i--) { swapDynArr(heap, 0, i); _adjustHeap(heap, i, 0);} }
void sortHeap(DynArr *heap) { assert( heap != NULL ); assert( sizeDynArr( heap ) > 0 ); _buildHeap( heap ); for( int i = ( sizeDynArr( heap ) - 1 ); i > 0; --i ) { /* Swap the outer two elements in the heap, then adjust it */ swapDynArr( heap, i, 0 ); _adjustHeap( heap, i, 0 ); } }
void sortHeap(DynArr *heap) { /* FIXME */ assert(heap->size != 0); _buildHeap(heap); //build heap data structure int last = sizeDynArr(heap) - 1; //last element of array while(last != 0) { swapDynArr(heap, last, 0); //swap elements between 1st and last element _adjustHeap(heap, last, 0); last--; } }
void sortHeap(DynArr *heap) { /* FIXME */ assert (sizeDynArr(heap) > 0); int i; int last = sizeDynArr(heap) - 1; /* build heap, then sort it (swap and adjust) */ _buildHeap(heap); for (i = last; i > 0; i-- ) { swapDynArr(heap, i, 0); _adjustHeap(heap, i, 0); } }
/* Print the list param: heap pointer to the list pre: the list is not empty post: The tasks from the list are printed out in priority order. The tasks are not removed from the list. */ void printList(DynArr *heap) { /* FIXME: Write this */ /* unable to effectively print in sorted order w/ tempArray, the following code is w/ help from tutor Dustin Castor */ assert(sizeDynArr(heap) > 0); /* sort and print in reverse in order that priority order is maintained */ sortHeap(heap); int i; int fin = sizeDynArr(heap)-1; /* last element */ for (i = fin; i >= 0; i--) { print_type(getDynArr(heap, i)); } /* rebuild to a heap from sorted array */ _buildHeap(heap); }