i wanted to know how to read values from a list into a binary tree. i have a triangle like this:
0
1 2
3 4 5
6 7 8 9
i have written a class node 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 bigger triangles. Can somehow tell me what i am supposed to do?
edit: quite clearly binary tree is not the way to approach this problem. what i basically want to find out are all the different combination's from top to bottom. like 0,1,3,6 0,2,5,8 etc.