I agree with the elegance. This is how heaps are stored in arrays: https://en.m.wikipedia.org/wiki/Heap_(data_structure)
Discussion
Also the sibling calculation is super simple:
sibling = ind + ((ind & 1) ? 1 : -1)
I agree with the elegance. This is how heaps are stored in arrays: https://en.m.wikipedia.org/wiki/Heap_(data_structure)
Also the sibling calculation is super simple:
sibling = ind + ((ind & 1) ? 1 : -1)