This file implements helper functions on trees. It uses a tree-like
representation with dictionaries, and the children are stored using
arrays. Each node possesses a val attribute labeling the node, and a children
attribute containing the array of its children. In a
Typescript-like description :
typeNode<A,B> = { val: A, children: B } typeTreeI<A> = Node<A, A[]>
This description does not allow for empty trees. A leaf | leaf is considered to be a node with an empty
array for its children.
This file implements helper functions on trees. It uses a tree-like representation with dictionaries, and the children are stored using arrays. Each
node
possesses aval
attribute labeling the node, and achildren
attribute containing the array of its children. In a Typescript-like description :This description does not allow for empty trees. A leaf |
leaf
is considered to be anode
with an empty array for its children.Example
Two ways to create a tree :