In this blog post we will investigate four key algorithms used to read through the content of a binary tree:
 BreadthFirst Traversal Algorithm
 DepthFirst Algorithms:
 PreOrder Traversal
 InOrder Traversal
 PostOrder Traversal
Binary Tree?
A Binary Tree is a data structure used in some algorithms to store data. In a binary tree each node can have up to two children.
BreadthFirst Traversal Algorithm
A Breadthfirst traversal consists of accessing each node, one level after the ohter. On each layer the nodes are accessed as they appear, from left to right.
DepthFirst Traversal Algorithms
There are three depthfirst traversal agorithms which are all based on a recursive approach.
PreOrder Traversal Algorithm:
1 2 3 4 5 6 7 
FUNCTION preordertraverse(tree) IF tree is not empty visit root node of tree preordertraverse(left subtree) preordertraverse(right subtree) END IF END FUNCTION 
InOrder Traversal Algorithm:
1 2 3 4 5 6 7 
FUNCTION inordertraverse(tree) IF tree is not empty inordertraverse(left subtree) visit root node of tree inordertraverse(right subtree) END IF END FUNCTION 
PostOrder Traversal Algorithm:
1 2 3 4 5 6 7 
FUNCTION postordertraverse(tree) IF tree is not empty postordertraverse(left subtree) postordertraverse(right subtree) visit root node of tree END IF END FUNCTION 
Binary Tree #1

Binary Tree #2

Binary Tree #3

Binary Tree #4
