class node():
    def __init__(self, value):
        self.left = None
        self.value = value
        self.right = None
        self.height = 0

    def insert(self, value):
        if self.value:
            if value < self.value:
                if self.left is None:
                    self.left = node(value)
                else:
                    self.left.insert(value)
            elif value > self.value:
                if self.right is None:
                    self.right = node(value)
                else:
                    self.right.insert(value)
            else:
                self.value = value

    def print_inorder(self):
        if self.left:
            self.left.print_inorder()
        print(self.value, end=" ")
        if self.right:
            self.right.print_inorder()

    def print_postorder(self):
        if self.left:
            self.left.print_postorder()
        if self.right:
            self.right.print_postorder()
        print(self.value, end=" ")

    def print_preorder(self):
        print(self.value, end=' ')
        if self.left:
            self.left.print_preorder()
        if self.right:
            self.right.print_preorder()


    def print_nth_row(self, n):
        if n==1:
            print(self.value, end=" ")
        self.left.print_nth_row(n-1)
        self.right.print_nth_row(n-1)



    def delete(self, value):
        if self.value > value:
            self.left.delete(value)
        elif self.value < value:
            self.right.delete(value)
        else:
            if self.right
            


a = [6, 7, 9, 4, 1, 3, 15, 17, 5, 2]

head = node(a[0])

for i in range(1, len(a)):
    head.insert(a[i])

head.print()

bc2288b2d84783283c5b91ada446a2fc78b77fb2
class node():
    def __init__(self, value):
        self.left = None
        self.value = value
        self.right = None
        self.height = 0

    def insert(self, value):
        if self.value:
            if value < self.value:
                if self.left is None:
                    self.left = node(value)
                else:
                    self.left.insert(value)
            elif value > self.value:
                if self.right is None:
                    self.right = node(value)
                else:
                    self.right.insert(value)
            else:
                self.value = value

    def print_inorder(self):
        if self.left:
            self.left.print_inorder()
        print(self.value, end=" ")
        if self.right:
            self.right.print_inorder()

    def print_postorder(self):
        if self.left:
            self.left.print_postorder()
        if self.right:
            self.right.print_postorder()
        print(self.value, end=" ")

    def print_preorder(self):
        print(self.value, end=' ')
        if self.left:
            self.left.print_preorder()
        if self.right:
            self.right.print_preorder()


    def print_nth_row(self, n):
        if n==1:
            print(self.value, end=" ")
        self.left.print_nth_row(n-1)
        self.right.print_nth_row(n-1)



    def delete(self, value):
        if self.value > value:
            self.left.delete(value)
        elif self.value < value:
            self.right.delete(value)
        else:
            if self.right
            


a = [6, 7, 9, 4, 1, 3, 15, 17, 5, 2]

head = node(a[0])

for i in range(1, len(a)):
    head.insert(a[i])

head.print()
