I wanted to know how to read values โโfrom a list into a binary tree. I have such a triangle:
0
1 2
3 4 5
6 7 8 9
i wrote a node class like this
class node:
def __init__(self,data,left=None,right=None):
self.data=data
self.left=left
self.right=right
basically what i want to do is something like this
node (0, node (1), node (2))
I want to make a recursive function that can handle much larger triangles. Can you somehow tell me what I should do?
edit: it is obvious that the binary tree is not a way to approach this problem. what I basically want to know is all different combinations from top to bottom. e.g. 0,1,3,6 0,2,5,8 etc.
johne source
share