Пример #1
0
def main():
    tree = rbt.RedBlackTree()
    tree.insert(14)
    tree.insert(42)
    tree.insert(35)
    tree.insert(7)
    tree.insert(26)
    tree.insert(17)
    rbt.preorder(tree.root)
Пример #2
0
            num = random.randint(1, 100)
            nAux.insert(i, num)
        nAux.sort()  #ordenando

        if (ops[1] == '0'):
            # BST
            print('bst')
            tree = bst.NodeBST(nAux[0])
        elif (ops[1] == '1'):
            # AVL
            print('avl')
            tree = avl.NodeAVL(nAux[0])
        elif (ops[1] == '2'):
            # RBT
            print('rbt')
            tree = rbt.RedBlackTree()
            tree.add(nAux[0])

        for i in range(1, n):
            tree.add(nAux[i])

    ########## MELHOR CASO: ALEATÓRIOS ##########
    elif (ops[0] == '1'):
        if (ops[1] == '0'):
            # BST
            print('bst')
            tree = bst.NodeBST(nAux[0])
        elif (ops[1] == '1'):
            # AVL
            print('avl')
            tree = avl.NodeAVL(nAux[0])
Пример #3
0
import hmap
import rbt
import bst
import time
import sys

a = hmap.HashMap(47, 1000000)
b = rbt.RedBlackTree()
c = bst.BST()
sys.setrecursionlimit(10000)

n = int(input())
porownaniahmap = 0
porownaniarbt = 0
porownaniabst = 0
polecenia = {"find": 0}
minhmap = 1000000000
minrbt = 1000000000
minbst = 1000000000
maxhmap = 0
maxrbt = 0
maxbst = 0

for i in range(n):
    message = input().split(' ')
    print(i)
    if message[0] == "insert":
        a.insert(message[1])
        b.insert(message[1])
        c.insert(message[1])
    elif message[0] == "find":