Tag: tree


Insertion in Binary Search Tree

Given a Binary Search Tree (BST) insert a new node in BST. Insertion in the binary search tree is always done as a leaf node. We have to traverse the binary search tree and find the right position ...

Search a node in Binary search tree

In this tutorial, we are going to learn that how to search a node in a Binary search tree using recursive and iterative solution.

Introduction to Binary Search Tree

A Binary Search Tree is a non-linear data structure in which all the left subtree keys should be less than the root key and all the right subtree keys should be greater than the root key. And both ...

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...