tree2vec {msBP} | R Documentation |
Conversions between tree and vector
Description
Convert a binary tree object into a vector and _vice versa_
Usage
tree2vec(tree)
vec2tree(vec)
Arguments
tree |
An object of the class binaryTree |
vec |
A vector of numbers. It must have size 2^s - 1, with s an integer. |
Details
An object of the class binaryTree is a binary tree containing at each node a value.
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
)
.
Examples
tree <- vec2tree(1:(2^5 - 1))
vector <- tree2vec(tree)
[Package msBP version 1.4-1 Index]