Skip to content

Category Archives: Tree

Given a sorted array. Write a function that creates a Balanced Binary Search Tree using array elements. Examples:  Input: arr[] = {1, 2, 3}Output: A… Read More
Write a function to connect all the adjacent nodes at the same level in a binary tree. The structure of the given Binary Tree node… Read More
Given a Binary Tree, The task is to connect all the adjacent nodes at the same level starting from the left-most node of that level,… Read More
Given two binary trees, check if the first tree is a subtree of the second one. A subtree of a tree T is a tree… Read More
Write a function that returns true if the given Binary Tree is SumTree else false. A SumTree is a Binary Tree where the value of… Read More
A Minimum Spanning Tree (MST) is a subset of the edges of a connected, undirected graph that connects all the vertices together, without any cycles… Read More
Given two values k1 and k2 where k1 < k2 and a root pointer to a Binary Search Tree. The task is to print all… Read More
Given a Binary Tree and a key, write a function that prints all the ancestors of the key in the given binary tree.  For example,… Read More
Given a Binary Tree and a key, write a function that returns level of the key.  For example, consider the following tree. If the input… Read More
Applications of tree data structure What is Tree Data Structure? A tree is a type of data structure that represents a hierarchical relationship between data… Read More
Given a root of a tree, and an integer k. Print all the nodes which are at k distance from root. For example, in the below… Read More
Given a binary tree, find out if the tree can be folded or not. A tree can be folded if the left and right subtrees… Read More
Given a binary tree, the task is to find the maximum width of the given tree. The width of a tree is the maximum of… Read More
Write a program that converts a given tree to its Double tree. To create Double tree of the given tree, create a new duplicate for… Read More
For the below example tree, all root-to-leaf paths are: 10 –> 8 –> 3 10 –> 8 –> 5 10 –> 2 –> 2 Recommended… Read More

Start Your Coding Journey Now!