def test_btree_lvl_order_4(self): r1 = TreeNode(0) r1.right = TreeNode(1) exp = [0, 1] act = TU.lvl_order(r1) self.assertEqual(exp, act)
def test_btree_lvl_order_6(self): r1 = TreeNode(0) r1.left = TreeNode(1) r1.right = TreeNode(2) r1.left.left = TreeNode(3) r1.left.left.right = TreeNode(4) r1.right.left = TreeNode(5) exp = [0, 1, 2, 3, 5, 4] act = TU.lvl_order(r1) self.assertEqual(exp, act)
def test_btree_lvl_order_2(self): r1 = TreeNode(0) exp = [0] act = TU.lvl_order(r1) self.assertEqual(exp, act)
def test_btree_lvl_order_1(self): r1 = None exp = [] act = TU.lvl_order(r1) self.assertEqual(exp, act)