Module tree_arithmetic
Source - zeroed
- expand_tree_index
- Return a node’s family.
index
is zero indexed. - general_index_to_subtree
- Translate the general index
index
into a subtree index rooted at root
. - is_in_subtree
- Determine if
index
is in the subtree rooted at root
. - last_power_of_two
- Return the last power of two for
n
using bit twiddling. - left_most_leaf
- Return the first leaf of a tree described by
root
and depth
. - log_base_two
- Return the log of
n
using the De Bruijn method.
https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn - next_power_of_two
- Return the next power of two for
n
using bit twiddling.
https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 - relative_depth
- Return the depth between two general indicies.
- right_most_leaf
- Return the last leaf of a tree described by
root
and depth
. - root_from_depth
- Return the subtree root for
index
assuming the tree is depth
deep. - sibling_index
- Return the index of a node’s sibling.
index
is zero indexed. - subtree_index_to_general
- Translate the subtree index
index
rooted at root
into a general index.