Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I'm trying to create an integer array that represents a heap.
I am almost finished, but still have two little problems.
when I remove an item, I set the heap to replace the removed item with the last item of the array and then call a method to re-organize the heap.
problem is that I can't seem to do it well, so any tips are welcome.
second problem is that since it is an integer array I had to make up a rule that if the number 0 occupies a spot in the heap, it means there is nothing there, but I want to be able to add the number 0 to the heap, so how can I fix that?