I am studying the heap sort algorithm from the book Introduction to Algorithms by Thomas H. Corman. It differentiates between the length of the array,
"the number of elements in the array"
"represents how many elements in the heap are stored within array
I am trying to visualize a case when
A.heapsize will not be equal to
- When does an element of a heap not reside in the array?
- Is there a practical scenario where
A.heapsize < A.length?
A.heapsizejust tells you, at any point during the execution, where the heap-containing part ends (and where the sorted array starts). You need this because the split is not physical (it's not actually two arrays) - you just maintain a "marker" to tell you where each part starts/ends. 2/2