Exemplo n.º 1
0
def generate_avl(data):
    data = json.loads(data)
    data = data["DATA"]
	
    list_dictionary = []
    addStudent(data, list_dictionary)
    new_avl = AVL()

    
    for student in list_dictionary:
    	student = str(student).split("-")
    	new_avl.add(int(student[0]), student[1])
	
    return new_avl
    
Exemplo n.º 2
0
def main():
    avl = AVL()
    value = 0

    value = int(input("Digite um numero: "))
    while value != -1:
        avl.add(value)
        avl.imprimir()
        value = int(input("Digite um numero: "))

    print("----REMOVER----")
    value = int(input("Digite um numero: "))
    while value != -1:
        avl.remove(value)
        avl.imprimir()
        value = int(input("Digite um numero: "))

    avl.imp()
class AVLtreeDict(AVL):
    '''A AVL-based implementation of a sorted dictionary'''
    def __init__(self):
        self._items = AVL()

    def __getitem__(self, key):
        '''Returns the value associated with key or returns None if key does not exist.'''
        return self._items.find(key)

    def __setitem__(self, key, value):
        self._items.add((key, value))

    def __contains__(self, key):
        return self.__getitem__(key) != None

    def __str__(self):
        return str(self._items)

    def __len__(self):
        return len(self._items)

    def __iter__(self):
        return iter(self._items)