How can you traverse a Binary Tree?

A binary tree can be traversed in three ways.
1. In Order traversal: The order of traversal is essentially L->N->R. So you traverse the left sub tree before you read the node and then you traverse the right sub tree.
2. Pre Order traversal: The order of traversal in this case is N->L->R. Traverse the node then the left subtree and then the right sub tree.
3. Post Order traversal: Order of traversal being L->R->N which says traverse the left subtree and the right subtree before you read the node.

In order to save some time and space I have clubbed together the working example of these traversals at this page.


core java 12


Explore Tutu'rself