Tag: binary-tree


All root-to-leaf paths of a Binary tree

Write a program to find all root to leaf paths of a Binary tree. A tree has different paths from the root to each leaf node, print all the possible paths from the root to each leaf node separately.

Diameter of a Binary tree

The diameter of a tree is the number of nodes on the longest path between two leaves in the tree. Here, we will try to find the diameter of a binary tree using an unoptimized solution first and the...

Maximum level sum in a binary tree

Write a program to find the maximum level sum in a binary tree even if nodes may have negative values also. To find the maximum level sum, traverse each level separately and find the sum of each le...

Compare structure and data of two binary trees

Write a program to compare the structure data of two binary trees and if they are identical then return true otherwise false by checking each node in the given binary trees.

Compare structure of two binary trees

Write a program to compare the structure of two binary trees without data and if they are identical then return true otherwise false by checking each node in the given binary trees.

Number of full nodes in a binary tree

Those nodes in the tree which have both the children are known as full nodes i.e., A node is a full node if both left and right child nodes of it are present or not null. To find the number of full...

Number of half nodes in a binary tree

Those nodes in the tree which have only one child are known as half nodes i.e., A node is a half node if only one child node is present among left or right child nodes. To find the number of half n...

Number of leaf nodes in a binary tree

Those nodes in the tree which don't have any child are known as leaf nodes i.e., A node is a leaf node if both left and right child nodes of it are null. To find the number of leaf nodes in a binar...

Deepest node in a binary tree

The rightmost node among the leaf nodes is known as the deepest node in a binary tree. Find the deepest node in a binary tree solution with examples and algorithm.

Size of a binary tree

Find the size of a Binary tree using recursion or iterative solution. For example, a binary tree contains elements- 1, 2, 3, 4, 5, 6, 7 SIze of the binary tree will be 7.