def testBFSSingleInsert(): print(divider + "Executing testBFSSingleInsert()...") nodes = [] tree = BinaryTree() tree.insert(Node(7)) nodes = tree.getNodesBFS() print(nodesToString(nodes)) assert (nodes[0].data == 7) print("Passed" + divider)
def testBFSRandom(): print(divider + "Executing testBFSRandom()...") tree = BinaryTree() expectedNodes = [32, 16, 50, 2, 30, 48, 53, 5, 18, 12] for num in randomNumbers: tree.insert(Node(num)) bfsNodes = tree.getNodesBFS() print(nodesToString(bfsNodes)) # Ensure that the order of the nodes is in the proper order for BFS for i in range(0, len(expectedNodes)): assert (bfsNodes[i].data == expectedNodes[i]) print("Passed" + divider)