Taken from CLRS third edition, a procedure is given for Build-Max-Heapfunction a = build_MaxHeap(a)for i = floor(length(a)/2): -1 : 1        // i = n downto 1     a = max_heapify(a,i);endMy question is why use floor(length(a)/2)? How is it different than using length(a)? Is this the same thing?function a = build_MaxHeap(a)for i = length(a): -1 : 1        // i = n downto 1     a = max_heapify(a,i);end
Build-Max-Heap: Why Start i at floor(A.length/2) rather than A.length?
algorithms;data structures;heaps