Exemplo n.º 1
0
from linked_binary_tree import LinkedBinaryTree

test_tr = LinkedBinaryTree(' a')
print(test_tr)
print("root_val ", test_tr.get_root_val())
print("left_child ", test_tr.get_left_child())
test_tr.insert_left(' b')
print("left_child ", test_tr.get_left_child())
print("left_child().get_root_val ", test_tr.get_left_child().get_root_val())
test_tr.insert_right(' c')
print("right_child ", test_tr.get_right_child())
print("right_child().get_root_val ", test_tr.get_right_child().get_root_val())
r.get_right_child().set_root_val(' hello')
print("right_child().get_root_val", test_tr.get_right_child().get_root_val())

print(test_tr)
Exemplo n.º 2
0
from linked_binary_tree import LinkedBinaryTree

test_tr = LinkedBinaryTree(' a')
#test_tr.is_empty()
print(test_tr)
print("root_val ", test_tr.get_root_val())
print("left_child ", test_tr.get_left_child())
test_tr.insert_left(' b')
print("left_child ", test_tr.get_left_child())
print("left_child().get_root_val ", test_tr.get_left_child().get_root_val())

test_tr.insert_left(' bb')
print("left_child ", test_tr.get_left_child())
print("left_child().get_root_val ", test_tr.get_left_child().get_root_val())

test_tr.insert_right(' c')
print("right_child ", test_tr.get_right_child())
print("right_child().get_root_val ", test_tr.get_right_child().get_root_val())
test_tr.get_right_child().set_root_val(' hello')
print("right_child().get_root_val", test_tr.get_right_child().get_root_val())

test_tr.inorder()

a_node = LinkedBinaryTree('A')
a_node.insert_left('B')
a_node.insert_right('C')

b_node = a_node.left_child
b_node.insert_right('D')

c_node = a_node.right_child