Пример #1
0
def bn2():
    tree = BinaryTree()
    root = Node("42")
    node_100 = Node("100")
    node_600 = Node("600")
    node_15 = Node("15")
    node_160 = Node("160")
    node_200 = Node("200")
    node_350 = Node("350")
    node_125 = Node("125")
    node_175 = Node("175")
    node_4 = Node("4")
    node_500 = Node("500")

    tree.root = root
    root.left = node_100
    root.right = node_600
    node_100.left = node_15
    node_100.right = node_160
    node_600.left = node_200
    node_600.right = node_350
    node_160.left = node_125
    node_160.right = node_175
    node_350.left = node_4
    node_350.right = node_500

    return tree
Пример #2
0
def bn1():
    tree = BinaryTree()
    root = Node("150")
    node_100 = Node("100")
    node_250 = Node("250")
    node_75 = Node("75")
    node_160 = Node("160")
    node_200 = Node("200")
    node_350 = Node("350")
    node_125 = Node("125")
    node_175 = Node("175")
    node_300 = Node("300")
    node_500 = Node("500")

    tree.root = root
    root.left = node_100
    root.right = node_250
    node_100.left = node_75
    node_100.right = node_160
    node_250.left = node_200
    node_250.right = node_350
    node_160.left = node_125
    node_160.right = node_175
    node_350.left = node_300
    node_350.right = node_500

    return tree
Пример #3
0
def bn_tree_ub():
    tree = BinaryTree()
    a = Node('A')
    b = Node('B')
    c = Node('C')
    d = Node('D')

    tree.root = a
    a.left = b
    a.right = c
    b.right = d

    return tree
Пример #4
0
def bn_mixed_tree():
    tree = BinaryTree()
    a = Node(6)
    b = Node(75)
    c = Node(34)
    d = Node(12)
    e = Node(1)
    f = Node(100)

    tree.root = a
    a.left = b
    a.right = c
    b.left = d
    b.right = e
    c.left = f

    return tree
Пример #5
0
def bn_tree():
    tree = BinaryTree()
    a = Node('A')
    b = Node('B')
    c = Node('C')
    d = Node('D')
    e = Node('E')
    f = Node('F')

    tree.root = a
    a.left = b
    a.right = c
    b.left = d
    b.right = e
    c.left = f

    return tree