本文整理汇总了Python中TreeNode.TreeNode.setDemo方法的典型用法代码示例。如果您正苦于以下问题:Python TreeNode.setDemo方法的具体用法?Python TreeNode.setDemo怎么用?Python TreeNode.setDemo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode.TreeNode
的用法示例。
在下文中一共展示了TreeNode.setDemo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from TreeNode import TreeNode [as 别名]
# 或者: from TreeNode.TreeNode import setDemo [as 别名]
re.append(root.val)
root = root.right
elif order =='LRN':
# after handle all left children or after handle all right children
# BOTH will make self = stack.pop()
stack = []
pre = None
while root!=None or len(stack)!=0:
if root != None:
stack.append(root)
root = root.left
elif stack[-1].right!=pre:# poped is no left or left has been handled
root = stack[-1].right
pre = None
else:
pre = stack.pop()
re.append(pre.val)
return re
demo = TreeNode(0)
demo.setDemo()
order = ['NLR','LNR','LRN']
for i in order:
print i,' : ',
for ch in visitTree_Iterative(demo,i):
print ch,
print