If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions.

This is 1st part of java binary tree tutorial.

- Binary tree in java
- Binary tree preorder traversal
- Binary tree postorder traversal
- Binary tree inorder traversal
- Binary tree level order traversal
- Binary tree spiral order traversal
- Binary tree reverse level order traversal
- Binary tree boundary traversal
- Print leaf nodes of binary tree
- Count leaf nodes in binary tree
- get maximum element in binary tree
- Print all paths from root to leaf in binary tree
- Print vertical sum of binary tree in java
- Get level of node in binary tree in java
- Lowest common ancestor(LCA) in binary tree in java

A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child

Example of binary tree:

I have posted various programs on binary tree so that you can practice them for interviews and it will also help in understanding recursion.

#### Binary tree traversals:

PreOrder traversal – In PreOrder traversal,each node is processed before either of its sub-trees.In simpler words,Visit each node before its children.

InOrder traversal : In InOrder traversal,each node is processed between subtrees.In simpler words,Visit left subtree, node and then right subtree.

PostOrder traversal: In PostOrder traversal,each node is processed after subtrees traversal.In simpler words,Visit left subtree, right subtree and then node.

Level order traversal : In Level order traversal, tree is traversed by each level. It is same as breadth first search.

Spiral/Zigzag order traversal : In spiral order traversal, tree is traversed in spiral shape.

Binary tree reverse level order traversal: It is similar to level order but in reverse

Binary tree boundary traversal : This traversal traverse boundary of binary tree

#### Other Binary tree programs:

- Program to print leaf nodes of a binary tree in java.
- Program to count leaf nodes in a binary tree in java.
- Program to print all paths from root to leaf in a binary tree in java.
- get maximum element in binary tree
- Print vertical sum of binary tree in java
- Get level of node in binary tree in java
- Lowest common ancestor(LCA) in binary tree in java

#### Join Our News Letter – Stay Updated

**Subscribe to Awesome Java Content**.

Found your blog. Its really nice on Binary tree in java programming. Its a great tutorial for the beginners. Really liked it. Thank you for all the information.

thank u very much for giving clear explanation.could u please give explanation for generalised list .please if it possible

You are the best blogger & teacher I have ever seen! You explain the core aspects of every subject and give no unnecessary detail.

Congrats!! 🙂

Awesome …neat and simple to understand. Keep up your good work. Thanks for your blogs.

Each and every explanation of urs is realy perfect.