Download presentation
Presentation is loading. Please wait.
1
if the tree is empty, do nothing,
else: (For preorder) visit root do left subtree do right subtree
2
if the tree is empty, do nothing,
else: (For inorder) do left subtree visit root do right subtree
3
if the tree is empty, do nothing,
else: (For postorder) do left subtree do right subtree visit root
4
if the tree is empty, do nothing,
else: (For preorder) visit root do left subtree do right subtree (For inorder) (For postorder)
5
void pre-traverse(Treenode p)
{ Treenode-stack A; Clear(A); while (true) if (p ≠ nil) { Visit(p); Stack(A, p); p ← p↑Llink; } else if (Empty(A)) return; { p ← Unstack(A); p ← p↑Rlink;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.