I'm trying to write a binary heap implemented over a binary tree, but I'm having trouble finding a way to add a new node to the "bottom" of the heap, i.e. the first null space on the tree in a breadth-first traversal. I've already got a working heapify function, but I can't figure out how to add a new node before heapifying.
I can't seem to think of a consistent algorithm that can find the null space that I can add my node to, every time I think I come up with something, it doesn't work. What do I do?