voidInsert(ElementTypeX,PriorityQueueH){inti;if(IsFull(H)){printf("Queue is full.\n");return;}for(i=++H->Size;H->Element[i/2]>X;i/=2)H->Elements[i]=H->Elements[i/2];H->Elements[i]=X;}
ElementTypeDeleteMin(PriorityQueueH){inti,Child;ElementTypeMinElement,LastElement;if(IsEmpty(H)){printf("Queue is empty.\n");returnH->Elements[0];}MinElement=H->Elements[1];LastElement=H->Elements[H->Size--];for(i=1;i*2<=H->Size;i=Child){// Find smaller child.Child=i*2;if(Child!=H->Size&&H->Elements[Child+1]<H->Elements[Child])Child++;// Percolate one level.if(LastElement>H->Elements[Child])H->Elements[i]=H->Elements[Child];elsebreak;}H->Elements[i]=LastElement;returnMinElement;}