Cause while doing so if v.size() == 8 then we will land up at 3 which is technically wrong.
Why in For Loop we used v.size()-1/2... Please explain
For every index greater than 3(using the same example as yours) left child will be at 4* 2+1(say for 8) that index doesn’t exist for array of size 8.
For 3,left child is at 3*2 +1 that index exist.
So,(v.size()-1)/2 gives the index of the highest index which have child.
Also, in heapify function you compare a node to its child.So, for every node when it will be called for heapify , also nodes below it should be in proper heap order.Hence we start from the highest index that have child.So that once we reah a particular index,we know for sure that all index after it are in heap order.
