Heap insertion- //ignore this

why did we reserve the first index of array?

Hey @vashishthkuntal.gajjar2019 reserve is used to store minimum capacity.

You can see it’s documentation here->link

Example is well explained it will clear your doubt.

ya i saw the same docs but why to do v.push_back(-1)?

This is because we have block the 0th index by pushing -1 in constructor

now 1st index is root node it has no parent

so we we move to parent only if idx>1
Try to Watch the video again it’s explained in detail.