Write a function to connect all the adjacent nodes at the same level in a binary tree. Structure of the given Binary Tree node is… Read More »
Given two binary trees, check if the first tree is subtree of the second one.
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 »
Minimum Spanning Tree (MST) problem: Given connected graph G with positive edge weights, find a min weight set of edges that connects all of the… 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.
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 »
Difficulty Level: Rookie Why Tree? Unlike Array and Linked List, which are linear data structures, tree is hierarchical (or non-linear) data structure.
Given a root of a tree, and an integer k. Print all the nodes which are at k distance from root.
Question: Given a binary tree, find out if the tree can be folded or not. A tree can be folded if left and right subtrees… Read More »
Given a binary tree, write a function to get the maximum width of the given tree. Width of a tree is maximum of widths 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:
Let us consider the below traversals: Inorder sequence: D B E A F C Preorder sequence: A B D E C F Recommended: Please solve… Read More »
Given a binary tree and a number, return true if the tree has a root-to-leaf path such that adding up all the values along the… Read More »
Using Morris Traversal, we can traverse the tree without using stack and recursion. The idea of Morris Traversal is based on Threaded Binary Tree.