def test_remove(tree): tree = bst.put(tree, 21, 'book21') tree = bst.put(tree, 7, 'book7') tree = bst.put(tree, 30, 'book30') tree = bst.put(tree, 5, 'book5') tree = bst.put(tree, 4, 'book4') tree = bst.put(tree, 3, 'book3') tree = bst.put(tree, 20, 'book20') tree = bst.put(tree, 25, 'book25') tree = bst.put(tree, 35, 'book35') tree = bst.put(tree, 29, 'book29') tree = bst.put(tree, 11, 'book11') tree = bst.put(tree, 15, 'book15') tree = bst.remove(tree, 21) tree = bst.put(tree, 10, 'book10') tree = bst.put(tree, 10, 'book10A') assert bst.contains(tree, 29) is True assert bst.contains(tree, 28) is False assert bst.minKey(tree) == 3 assert bst.maxKey(tree) == 35 bst.deleteMin(tree) assert bst.contains(tree, 3) is False
def deleteMin(map): """ Encuentra y remueve la menor llave de la tabla de simbolos y su valor asociado Args: map: La tabla de simbolos Returns: La tabla de simbolos sin la menor llave Raises: Exception """ if (map['type'] == 'BST'): return bst.deleteMin(map) else: return rbt.deleteMin(map)
def test_delete_max_min(tree): tree = bst.put(tree, 23, 'book21') tree = bst.put(tree, 7, 'book7') tree = bst.put(tree, 30, 'book30') tree = bst.put(tree, 5, 'book5') tree = bst.put(tree, 4, 'book4') tree = bst.put(tree, 3, 'book3') tree = bst.put(tree, 20, 'book20') tree = bst.put(tree, 25, 'book25') tree = bst.put(tree, 35, 'book35') tree = bst.put(tree, 29, 'book29') tree = bst.put(tree, 11, 'book11') tree = bst.put(tree, 15, 'book15') tree = bst.put(tree, 10, 'book10') assert bst.contains(tree, 3) is True assert bst.size(tree) == 13 bst.deleteMin(tree) assert bst.contains(tree, 3) is False assert bst.size(tree) == 12 assert bst.contains(tree, 35) is True assert bst.size(tree) == 12 bst.deleteMax(tree) assert bst.contains(tree, 35) is False assert bst.size(tree) == 11