bartz.grove.tree_depths

bartz.grove.tree_depths(heap_size)[source]

Return the depth of each node in a binary tree.

Parameters:

heap_size (int) – The length of the heap array.

Returns:

UInt[Array, '{heap_size}'] – The depth of each node.

Notes

The root node (index 1) has depth 0. The depth is the position of the most significant non-zero bit in the index. The first element (the unused node) is marked as depth 0.