I have the first tree node. Something like that:
class TreeNode {
int uniqueValue;
List<TreeNode> children;
}
I want to find the most memory efficient way to print all the nodes of a tree. A tree can be large or VERY BIG. It can be deep or wide. I know recursion and glass algorithms. I want to find an algorithm that uses a fixed amount of memory regardless of the size of the graph.
The tree is not binary!
source
share