Count non leaf nodes in binary tree in java (BFS /examples)

What is non leaf node in binary tree?
A node in a binary tree which has child node(s) is called non leaf node.
Non Leaf Node can be Node having one child or both children:
One child (Either left child or right child)
Two children (Both left child and right child)

Find number of leaf nodes in a binary tree (Java/ BFS /example)

What is leaf node in binary tree?
A node in a binary tree which do not have any child nodes is called leaf node. The leaf node do not have any children i.e. left and right reference both null. We have to count the number of leaf nodes in the binary tree. In other ways we need to find out all the nodes in the binary tree which do not have any children (both right node and left node null).
So as per our problem statement, we have to iterate over the binary tree and find the number of leaf nodes in the binary tree.

Delete all nodes of a binary tree in java (recursive/ DFS/ example)

To delete binary tree, we have to delete all the nodes in the tree. We have discussed about deleting the node in binary search tree in separate post. Before we discuss about deleting tree, we will start from very small tree, then we will use this foundation to delete the whole tree. Suppose we have tree of 3 nodes

Create fixed thread pool in java using Executors (example)

Thread Pool : Thread pool is collection of threads which are created to complete certain tasks.
The interaction between thread pool and task is as follows
1.) Thread Pool is created
2.) Task are created.
3.) Task assigned to Thread in thread pool.

What is thread in java with example (Real world analogy) ?

Everybody in this world is performing one duty or the other.The duties we are performs is like the functional activity of bigger execution block. Let us shrink our vision and take one house to understand. In traditional family environment husband involves in earning to maintain day to day expenses and wife involves in house hold activitie

What is client server architecture with example (real world analogy) ?

The person or device that is capable of serving is called the Server. In our day to day life we come across various servers. We generally purchase vegetable or fruits from a vendor (Shopkeeper / hawker). We request the shopkeeper for required vegetables/fruits. The shop keeper provides us the required vegetable or fruits. We ask the shopkeeper and he provides us the food items. So, Shopkeeper is at our service, which fulfills our need.

Scroll to Top