本文整理汇总了Python中util.tree_node.TreeNode.compare_tree方法的典型用法代码示例。如果您正苦于以下问题:Python TreeNode.compare_tree方法的具体用法?Python TreeNode.compare_tree怎么用?Python TreeNode.compare_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.tree_node.TreeNode
的用法示例。
在下文中一共展示了TreeNode.compare_tree方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_case3
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case3(self):
nums = [6,5,8,1,3,7,11,None,None,None,None,None,None,9]
answer = [6,3,8,1,5,7,11,None,None,None,None,None,None,9]
root = TreeNode.generate_bt_from_list(nums)
self.sol.recoverTree(root)
compare = TreeNode.compare_tree(root, TreeNode.generate_bt_from_list(answer))
self.assertTrue(compare)
示例2: test_case1
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case1(self):
nums = [3,1,2]
answer = [2,1,3]
root = TreeNode.generate_bt_from_list(nums)
self.sol.recoverTree(root)
compare = TreeNode.compare_tree(root, TreeNode.generate_bt_from_list(answer))
self.assertTrue(compare)
示例3: test_case11
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case11(self): #===>
nums = "98,97,#,88,#,84,#,79,87,64,#,#,#,63,69,62,#,#,#,30,#,27,59,9,#,#,#,3,#,0,#,-4,#,-16,#,-18,-7,-19,#,#,#,-23,#,-34,#,-42,#,-59,#,-63,#,-64,#,-69,#,-75,#,-81"
answer = "98,#,97,#,88,#,84,#,79,#,64,#,63,#,62,#,30,#,27,#,9,#,3,#,0,#,-4,#,-16,#,-18,#,-19,#,-23,#,-34,#,-42,#,-59,#,-63,#,-64,#,-69,#,-75,#,-81,#,-7,#,59,#,69,#,87"
from util.tree_node import TreeNode
root = TreeNode.generate_bt_from_string_standard(nums)
answer_tree = TreeNode.generate_bt_from_string_standard(answer)
self.sol.flatten(root)
compare = TreeNode.compare_tree(root, answer_tree)
self.assertTrue(compare)
示例4: test_case1
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case1(self):
preorder = "abc"
inorder = "bac"
answer = TreeNode("a")
answer.left = TreeNode("b")
answer.right = TreeNode("c")
result = self.sol.buildTree(preorder, inorder)
compare = TreeNode.compare_tree(answer, result)
self.assertTrue(compare)
开发者ID:linglingithub,项目名称:testhello,代码行数:11,代码来源:construct_binary_tree_from_preorder_and_inorder_traversal.py
示例5: test_case1
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case1(self):
nums = [1,2,3,4,5]
#answer = [3,1,4,None,2, None,5] # -- array way
answer = [3,2,5,1, None,4] # -- list way
result = self.sol.sortedListToBST(ListNode.parseArray2List(nums))
self.assertEqual(True, TreeNode.compare_tree(result,TreeNode.generate_bt_from_list(answer)))
示例6: test_case1
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case1(self):
nums = ListNode.parseArray2List([1,2,3,4,5,6,7])
answer = TreeNode.generate_bt_from_list([4,2,6,1,3,5,7])
result = self.sol.sortedListToBST(nums)
self.assertTrue(TreeNode.compare_tree(answer, result))
示例7: test_case1
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case1(self):
A = [6,4,20]
answer = "20,6,#,#,4" # wrong output "6,#,20,4"
result = self.sol.maxTree(A)
answer_tree = TreeNode.generate_bt_from_string_standard(answer)
self.assertTrue(TreeNode.compare_tree(answer_tree, result))
示例8: test_case1
# 需要导入模块: from util.tree_node import TreeNode [as 别名]
# 或者: from util.tree_node.TreeNode import compare_tree [as 别名]
def test_case1(self):
inorder = [4,2,5,1,6,3]
postorder = [4,5,2,6,3,1]
answer = TreeNode.generate_bt_from_list([1,2,3,4,5,6])
result = self.sol.buildTree(inorder, postorder)
self.assertTrue(TreeNode.compare_tree(answer, result))
开发者ID:linglingithub,项目名称:testhello,代码行数:8,代码来源:construct_binary_tree_from_inorder_and_postorder_traversal.py