def lrm_f(self,root):
stack=[]
result_stack=[]
if root is not None:
stack.append(root)
while len(stack)!=0:
root=stack.pop()
result_stack.append(root)
if root.left is not None:
stack.append(root.left)
if root.right is not None:
stack.append(root.right)
while len(result_stack)!=0:
result3.append(result_stack.pop().val)
stack=[]
result_stack=[]
if root is not None:
stack.append(root)
while len(stack)!=0:
root=stack.pop()
result_stack.append(root)
if root.left is not None:
stack.append(root.left)
if root.right is not None:
stack.append(root.right)
while len(result_stack)!=0:
result3.append(result_stack.pop().val)
全部评论
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享
09-23 13:46
河南师范大学 算法工程师 点赞 评论 收藏
分享
10-30 18:20
第一拖拉机制造厂拖拉机学院 C++
牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学 点赞 评论 收藏
分享

