Algorithms
Algorithms copied to clipboard
Heapsort nitpicking
trafficstars
https://github.com/williamfiset/Algorithms/blob/039cfc4efe849228f5af224956fa45d835732efa/src/main/java/com/williamfiset/algorithms/sorting/Heapsort.java#L21-L36
- Since you are checking
n / 2 - 1is non-negative anyways in line 27, probably it is more elegant to checknis more than 1 before that (whennis 0 or 1, the array is already sorted and we can return early) - At line 32 sinking index 0 is redundant.