$tree = [[], $key, []]; sub traverse; sub traverse { return unless @{$_ [0]}; traverse $_ [0] [0]; print $_ [0] [1]; traverse $_ [0] [2]; }
That's an in-order traversal. Your structure has the advantage that it can deal with any number of children, while the code above assumes 2 children for each non-empty node; as is common for binary trees.
Abigail
In reply to Re: Recursion, tree parsing.
by Abigail-II
in thread Recursion, tree parsing.
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |