At this point, the largest item is stored at the root of the heap. Replace it with the last item of the heap followed by reducing the size of heap by 1. Finally, heapify the root of the tree.
Repeat step 2 while size of heap is greater than 1.
Description of Change
Checklist
[ ] Description of change added
[ ] Added documentation
[ ] Added examples and/or tests
[ ] Documentation modified
[ ] Implemented a new algorithm
[ ] Re-implemented an existing algorithm
[ ] Checked that PR is not a duplicate
[ ] PR and commits are not on master branch
[ ] Issue fix
[ ] UI change
[ ] Screenshot and/or link of deployment where it can be tested
Your algorithm seems to be an implementation of an algorithm we already have. Please refer to the contribution guidelines, before continuing with this PR.
Description of Change
Checklist
Link: