Example #1
0
 def test_balance_left(self):
     a = Node(3)
     a.left = Node(2)
     a.left.left = Node(1)
     a.right = Node(4)
     Node.fixheight(a.left.left)
     Node.fixheight(a.left)
     Node.fixheight(a)
     Node.fixheight(a.right)
     Node.balance(a.left.left)
     self.assertEqual(-1, Node.bfactor(a))
Example #2
0
 def test_balance(self):
     a = Node(2)
     a.left = Node(1)
     a.right = Node(3)
     a.right.right = Node(4)
     a.right.left = Node(5)
     a.right.height = 3
     a.left.height = 1
     a.right.right.height = 4
     a.right.left.height = 5
     Node.balance(a)
     self.assertEqual(-1, Node.bfactor(a))