-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (40 loc) · 1.12 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from redblacktree import RedBlackTree
import os
def print_tree(node):
"""Ascending order"""
if node.value == None :
return
print_tree(node.right)
print(node)
print_tree(node.left)
try:
tree = RedBlackTree()
except:
print('erro')
number = 1
while(number):
print("Digite:\n1- Para adicionar a árvore.\n2- Para remover da árvore\n0- Para sair\n")
number = int(input())
if number == 1:
print("Digite o valor que queira adicionar.")
value = int(input())
tree.add(value)
root = tree.root
print_tree(root)
elif number == 2:
print("Digite o valor que deseje remover.")
value = int(input())
result = tree.remove(value)
if result:
print("Valor: {} retirado com sucesso.".format(value))
root = tree.root
print_tree(root)
else:
print("Valor não se encontra na árvore.")
print("Aperte enter para continuar!!!")
try:
input()
except:
print("Você está no python2 por favor aperte enter de novo")
raw_input()
os.system('clear')