If i create a heap array inside a loop, do i have to delete it at the end of each loop before i reinitialize it at the beginning of the loop again or will reinitializing the exact same thing again simply overwrite the old array and i can just skip the delete command?
Share
Do you mean something like this?
In that case: yes, you do need to delete the array.
If you had written something like this instead,
then no, you can reuse the array across multiple iterations of the loop.