###### tags: `learning` `algorithm` `zxm`
Asking zxm for tree problems
===
## Suppose I have a tree
```graphviz
digraph G {
nodesep=0.4;
ranksep=0.5;
{rank=same; B; E;}
{rank=same; C; D;}
{rank=same; F; G;}
A -> B;
A -> E;
B -> C;
B -> D;
E -> F;
E -> G
}
}
```
## I want to go through all paths, starting from the root, ending at a leaf.
So, the print-out is
```
ABC
ABD
AEF
AEG
```
## I have come out with an approach by cutting off each leaf arrived.
However, this approach alters the exiting data structure. Even though I can avoid the change by copying the whole tree, there is extra usage of memory.