摘要: 1、二叉树的中序遍历 用递归太慢,故使用颜色标记法,和递归思想差不多 white,gray=0,1 #定义标记颜色 res=[] stack=[(white,root)] #记录标记颜色和节点 while stack: color,node = stack.pop() #循环出站遍历栈中节点 if 阅读全文
posted @ 2022-07-20 23:50 肥余 阅读(44) 评论(0) 推荐(0)