コード例 #1
0
    def test_bubble_down(self):
        tree = AVL(Node(5))
        tree._bubble_down_to_place(tree.get_root(), Node(12))
        tree._bubble_down_to_place(tree.get_root(), Node(0))
        tree._bubble_down_to_place(tree.get_root(), Node(6))
        tree._bubble_down_to_place(tree.get_root(), Node(8))

        node_5 = tree.get_root()
        node_12 = node_5.get_right_child()
        node_0 = node_5.get_left_child()
        node_6 = node_12.get_left_child()
        node_8 = node_6.get_right_child()

        expect(node_5.get_key()).to.be.equal(5)
        expect(node_12.get_key()).to.be.equal(12)
        expect(node_0.get_key()).to.be.equal(0)
        expect(node_6.get_key()).to.be.equal(6)
        expect(node_8.get_key()).to.be.equal(8)