def test_breadth_first_mostly_left_side_nodes(self): bt = BinaryTree() bt.root = BinaryTreeNode(1) bt.root.left = BinaryTreeNode(2) bt.root.right = BinaryTreeNode(3) bt.root.left.left = BinaryTreeNode(4) bt.root.left.right = BinaryTreeNode(5) bt.root.right.right = BinaryTreeNode(7) bt.root.left.left.left = BinaryTreeNode(6) bt.root.left.left.left.left = BinaryTreeNode(8) result, depth = bt.breadth_first() self.assertEqual(result, [1, 2, 3, 4, 5, 7, 6, 8]) self.assertEqual(depth, 4)
def test_breadth_first_empty_tree(self): bt = BinaryTree() result, depth = bt.breadth_first() self.assertEqual(result, []) self.assertEqual(depth, 0)