This question is seeking an alternative to the answers given in this post.
How can I create a string which has each level of the tree on a new line with the following Binary Tree Structure:
# A Node is an object
# - value : Number
# - children : List of Nodes
class Node:
def __init__(self, value, children):
self.value = value
self.children = children
My problem is that I'm used to Tree Structures like this:
class Node(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
Here is an example tree:
exampleTree = Node(1,[Node(2,[]),Node(3,[Node(4,[Node(5,[]),Node(6,[Node(7,[])])])])])
That would print as:
1
23
4
56
7
Any help or ideas on how to create a definition using that new structure would be very appreciated.