So I am working on a project to implement a heap and heapsort, but it should be implemented with nodes(with parent, left, right pointers) instead of the usual array implementation.
It seems pretty straightforward, but the one thing I can't figure out is how to figure out where to add a new item to the tree.
In an array implementation, you would simply add the item to the next empty spot in the array (array.length index). However with a node-only implementation, it's not that simple.
I'm sure I could write some algorithm that loops through the entire tree until it finds the next empty spot, but that seems like it would take a ton of unnecessary time.
Does anyone have any ideas?