二项队列添加元素
from my csdn blog
二项队列,添加一个元素到队列中,不可用使用二项树合并函数。
//insert x into the binomial queue
BinQueue Insert(int x, BinQueue H){
int i;
BinTree Carry;
if(H->CurrentSize+1 > Capacity){
printf("no space for %d", x);
return H;
} //check the capacity
H->CurrentSize++; //inc the size of H
Carry = createBinTree();
Carry->element = x;
Carry->leftChild = Carry->nextSibling = NULL; // initialize the carry
i = 0;
while(H->TheTrees[i]){
Carry = CombineTrees(Carry, H->TheTrees[i]); //calculate the carry for high bit
H->TheTrees[i++] = NULL; //clean the TheTrees[i]
}
H->TheTrees[i] = Carry; //find the nonexistent position to place the carry
return H;
}