Heap grandparent

I'm about to code a min-max heap using a vector, and in order to do so I need to be able to access an element's parent and grandparent. I know that the formula for the index of one's parent is the floor of:

(index - 1)/2

So for the grandparent, I figured I could just apply the same formula twice, resulting in the formula:

(index - 3)/4

Do you think this is a fair conclusion for finding the grandparent?
Last edited on
Topic archived. No new replies allowed.