0% found this document useful (0 votes)
48 views3 pages

Inorder Traversal Algorithm

This document describes three tree traversal algorithms: InOrder, PreOrder, and PostOrder. InOrder first traverses the left subtree, then visits the root, then the right subtree. PreOrder first visits the root, then the left subtree, then the right subtree. PostOrder first traverses the left subtree, then the right subtree, then visits the root.

Uploaded by

sam4ets
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

Inorder Traversal Algorithm

This document describes three tree traversal algorithms: InOrder, PreOrder, and PostOrder. InOrder first traverses the left subtree, then visits the root, then the right subtree. PreOrder first visits the root, then the left subtree, then the right subtree. PostOrder first traverses the left subtree, then the right subtree, then visits the root.

Uploaded by

sam4ets
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 3

InOrder Traversal Algorithm

// InOrder traversal algorithm inOrder(TreeNode<T> n) { if (n != null) { inOrder(n.getLeft()); visit(n) inOrder(n.getRight()); } }

PreOrder Traversal Algorithm


// PreOrder traversal algorithm PreOrder(TreeNode<T> n) { if (n != null) { visit(n) PreOrder(n.getLeft()); PreOrder(n.getRight()); } }

PostOrder Traversal Algorithm


// PostOrder traversal algorithm PostOrder(TreeNode<T> n) { if (n != null) { PostOrder(n.getLeft()); PostOrder(n.getRight()); visit(n) } }

You might also like