在Python 3python如何遍歷二叉搜索樹使用inorder/pre/post /沒有遞歸?
class BinaryTree:
"""
=== Private Attributes ===
@type _root: object | None
@type _left: BinaryTree | None
@type _right: BinaryTree | None
"""
def __init__(self, root, left, right):
if root is None:
# store an empty BinaryTree
self._root = None
self._left = None
self._right = None
else:
self._root = root
self._left = left
self._right = right
def is_empty(self):
return self._root is None
我知道如何遞歸遍歷這個二叉樹,但我想知道如何做到這一點不遞歸
http://meta.softwareengineering.stackexchange.com/questions/6166/open-letter-to-students-with -homework-problems –