Array – what is the difference between a.length and a.heap-size?
•
Java
I have a question about heap sorting It points out in the book "algorithm" that a.heap-size < = a.length
Solution
The invariant of heap sorting is that the first k elements of the N-element array are the heap on the K smallest elements, and the last n-k elements are the n-k largest elements in the sorting order The latter element is why the heap does not occupy the entire array
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码