خرید بک لینک

Vote count: 0

i'm trying to create a binary tree using a given input in the first line is the number of nodes=4,root=0,depth=2 and the next line are the edges

How can i implement a function which reads from the standard input and draws the graph according to the input

Input

4 0 2
0 1
0 3
2 3

My Code

class BinaryTree(object):

    def __init__(self, root):
        self.left = None
        self.right = None
        self.root = root

    def left_child(self):
        retu self.left  

    def right_child(self):
        retu self.right

    def node_value(self, value):
        self.root = value

    def get_node(self):
        retu self.root

    def in_order(self, tree):
        if tree is not None:
            in_order(tree.left_child())
            print(tree.get_node())
            in_order(tree.right_child())

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 5 فروردين 1395 ساعت: 7:42

صفحه بندی