コード例 #1
0
ファイル: dynamicArray.c プロジェクト: dot1q/Misc
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);
	}
}
コード例 #2
0
void sortHeap(DynArr *heap)
{
    _buildHeap(heap);
    int i;
    for(i=sizeDynArr(heap)-1; i>0; --i) {
        swapDynArr(heap, i, 0);
        _adjustHeap(heap, i, 0);
    }

}
コード例 #3
0
ファイル: dynArray.c プロジェクト: Mankee/CS261
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);
    }

}
コード例 #4
0
void sortHeap(DynArr *heap)
{
	_buildHeap(heap);

	int last = heap->size - 1;

	while (last > 0)
	{
		swapDynArr(heap, 0, last);
		_adjustHeap(heap, last, 0);
		last--;
	}
}
コード例 #5
0
void sortHeap(DynArr *heap)
{
   /* FIXME */

	_buildHeap(heap);

	for(int i=sizeDynArr(heap)-1; i>0; i--)
		{
			swapDynArr(heap, 0, i);
		
			_adjustHeap(heap, i, 0);}

}
コード例 #6
0
ファイル: dynamicArray.c プロジェクト: jonese8/cs261
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 );
        }
}
コード例 #7
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--;
    }
}
コード例 #8
0
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);
    }

}
コード例 #9
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);


}