tree2vec {msBP} | R Documentation |
Convert a binary tree object into a vector and _vice versa_
tree2vec(tree) vec2tree(vec)
tree |
An object of the class binaryTree |
vec |
A vector of numbers. It must have size 2^s - 1, with s an integer. |
An object of the class binaryTree is a binary tree containing at each node a value.
A vector of size 2^{D+1}-1, where D is the depth of the binary tree, or a binary tree with depth \log_2(length(vec) + 1
).
tree <- vec2tree(1:(2^5 - 1)) vector <- tree2vec(tree)