Initialize current as root
While current is not NULL
If current does not have right child
a) print current root
b) Go to the left, i.e., current = current->left
Else
a) print current root
a) Make the whole right sub-tree of current as the left node of the rightmost child in the left sub tree(inorder predecessor of current)
b) Go to the left child, i.e., current = current->left
1 回答
刚刚制定出预订遍历的解决方案,可能会有效
如果算法出现问题,请发表评论