modified binheap.c