Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny656 committed Jan 10, 2024
1 parent 18b7b92 commit 4288aa9
Showing 1 changed file with 0 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@

typedef int ElementType;
#define MinData -1

typedef struct HeapStruct *PriorityQueue;
struct HeapStruct {
ElementType *Elements;
int Capacity;
int Size;
};

PriorityQueue Initialize( int MaxElements ); /* details omitted */

void PercolateUp( int p, PriorityQueue H );
void PercolateDown( int p, PriorityQueue H );

void Insert( ElementType X, PriorityQueue H )
{
int p = ++H->Size;
H->Elements[p] = X;
PercolateUp( p, H );
}

ElementType DeleteMin( PriorityQueue H )
{
ElementType MinElement;
MinElement = H->Elements[1];
H->Elements[1] = H->Elements[H->Size--];
PercolateDown( 1, H );
return MinElement;
}

void PercolateUp( int p, PriorityQueue H ) {
while (p > 1) {
int parent = p / 2;
Expand Down

0 comments on commit 4288aa9

Please sign in to comment.