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