MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / test_tree_chaining

Function test_tree_chaining

data_structures/binary_tree/red_black_tree.py:673–681  ·  view source on GitHub ↗

Tests the three different tree chaining functions.

()

Source from the content-addressed store, hash-verified

671
672
673def test_tree_chaining() -> bool:
674 """Tests the three different tree chaining functions."""
675 tree = RedBlackTree(0)
676 tree = tree.insert(-16).insert(16).insert(8).insert(24).insert(20).insert(22)
677 if list(tree.inorder_traverse()) != [-16, 0, 8, 16, 20, 22, 24]:
678 return False
679 if list(tree.preorder_traverse()) != [0, -16, 16, 8, 22, 20, 24]:
680 return False
681 return list(tree.postorder_traverse()) == [-16, 8, 20, 24, 22, 16, 0]
682
683
684def print_results(msg: str, passes: bool) -> None:

Callers 2

pytestsFunction · 0.85
mainFunction · 0.85

Calls 5

insertMethod · 0.95
inorder_traverseMethod · 0.95
preorder_traverseMethod · 0.95
postorder_traverseMethod · 0.95
RedBlackTreeClass · 0.85

Tested by

no test coverage detected