Пример #1
0
 def test_big(self):
     root = TreeNode(
         9,
         left=TreeNode(8, left=TreeNode(4), right=TreeNode(2)),
         right=TreeNode(7, left=TreeNode(6), right=TreeNode(5)),
     )
     self.assertEqual(root.postorder_traversal(), [4, 2, 8, 6, 5, 7, 9])
Пример #2
0
 def test_root_only(self):
     node = TreeNode(77)
     self.assertEqual(node.postorder_traversal(), [77])
Пример #3
0
 def test_example(self):
     root = TreeNode(4, left=TreeNode("a"), right=TreeNode(7, left=TreeNode(2)))
     self.assertEqual(root.postorder_traversal(), ["a", 2, 7, 4])