I learned that when you have a binary heap represented as a vector / list / array with indicies [0, 1, 2, 3, 4, 5, 6, 7, 8, …] the index of the parent of element at index i can be found with parent index = floor((i-1)/2)
I have tried to explain why it works. Can anyone help me verify this?
Took reference from Why does the formula 2n + 1 find the child node in a binary heap? thanks to @Giulio