Tree
Implementation of tree.
TreeNode:__init(key, val)
Constructor.
TreeNode:children()
Returns:
- (
table
) children of this node
TreeNode:__tostring__()
Returns:
- (
string
) string representation
TreeNode:subtreeToString(prefix, isLeaf)
Arguments:
prefix
(string
): string to add before each line.isLeaf
(boolean
): whether the subtree is a leaf.
Returns:
- (
string
) string representation
Tree:__tostring__()
Returns:
- (
string
) string representation
Tree:size()
Returns:
- (
int
) number of nodes in the tree