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

Function test_tree_traversal

data_structures/binary_tree/red_black_tree.py:657–670  ·  view source on GitHub ↗

Tests the three different tree traversal functions.

()

Source from the content-addressed store, hash-verified

655
656
657def test_tree_traversal() -> bool:
658 """Tests the three different tree traversal functions."""
659 tree = RedBlackTree(0)
660 tree = tree.insert(-16)
661 tree.insert(16)
662 tree.insert(8)
663 tree.insert(24)
664 tree.insert(20)
665 tree.insert(22)
666 if list(tree.inorder_traverse()) != [-16, 0, 8, 16, 20, 22, 24]:
667 return False
668 if list(tree.preorder_traverse()) != [0, -16, 16, 8, 22, 20, 24]:
669 return False
670 return list(tree.postorder_traverse()) == [-16, 8, 20, 24, 22, 16, 0]
671
672
673def test_tree_chaining() -> bool:

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