Tag: binary-tree


Height of a binary tree

Height of a tree is the total number of nodes on the path from the root node to the deepest …

Introduction to Binary Tree

A binary tree is a non-linear and hierarchical data structure which has zero children, one child or two children. An …

Binary tree traversals

Binary tree traversals can be done by Depth-first traversal and Breadth-first traversals or Level order traversal. Preorder traversal, Inorder traversal …

Reverse level order traversal

Program to print reverse level order traversal of a binary tree i.e., print data in a binary tree from …

Maximum in Binary tree

Find the maximum element in a Binary tree using recursion or iterative solution. For example, a binary tree contains the …

Search a node in Binary tree

Search a node in a Binary tree using recursion or iterative solution. For example, a binary tree contains the following …

Size of a binary tree

Find the size of a Binary tree using recursion or iterative solution. For example, a binary tree contains the following …

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 …

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 …

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 …

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 …

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 …

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 …

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 …

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 …

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 …