Problems

Binary Trees is a very famous topic from which questions are asked in the interviews of the Top Product-Based Companies. Hence, you must solve different problems on Binary Tree such as traversals on Binary Tree, Printing all the views of a Binary Tree, etc.

Check If Binary Tree Is BST Or Not

By Harsh goyal

● Published At Jan 2022

This blog will cover the brute force approach to check if a binary tree is BST or not and take you to the efficient approach to solve this problem.... Keep reading ..

Diameter of Binary Tree

By Yogesh Kumar

● Published At Oct 2021

This article will discuss the Diameter of a Binary Tree. We will look at its basic concepts, definitions, algorithms, and implementation in C++.
... Keep reading ..

Convert a given Binary Tree to a Doubly Linked List

By Yogesh Kumar

● Published At Oct 2021

In this article, we will be converting a Binary tree to a Doubly linked list. We will look at its basic concepts, definitions, algorithms, and implementation in C++.... Keep reading ..

Symmetric Binary Tree

By ANKIT MITTAL

● Published At Jan 2022

In this blog, we will learn about what is a symmetric binary tree and how to check whether a tree is a symmetric binary tree or not.
... Keep reading ..

Height of a Binary Tree

By ANKIT MITTAL

● Published At Jan 2022

In this blog, we will learn to calculate a binary tree’s height in the C++ programming language. ... Keep reading ..

Construct a Binary Tree from a given Postorder and Inorder traversal

By Nikhil Nischal

● Published At Oct 2021

This article is to construct a binary tree from a given postorder and inorder traversal. ... Keep reading ..

Construct a Binary Tree from a given Preorder and Inorder traversal

By Aniket verma

● Published At Oct 2021

This article will brief you on constructing a binary tree from a given preorder and inorder traversal.... Keep reading ..

Sum Of Distance Of All Nodes From A Given Node

By Harsh Goyal

● Published At Dec 2021

This article will discuss the Sum of the distance of all Nodes from a given node problem and various ways to solve this problem, from the brute force approach to the efficient approach.... Keep reading ..

Calculate the Dot Product of Ancestors of Two Given Nodes

By Firdausia Fatima

● Published At Jan 2022

In this blog, we’ll be solving a tree problem, calculate the dot product of ancestors of two given nodes using Backtracking.... Keep reading ..

Maximum average of subtree values in a given Binary Tree

By Sandeep kamila

● Published At Dec 2021

This article covers the implementation of the maximum average of subtree values in a given binary tree with a complete explanation and its C++ code.... Keep reading ..

Count Number of Nodes

By AMAN KUMAR CHOURASIYA

● Published At Nov 2021

Binary Tree is a widely asked data structure in interviews and programming contests. We will discuss different approaches to count the number of nodes in a complete binary tree.
... Keep reading ..

How to count the number of nodes in a complete binary tree

By Gorakhnath yadav

● Published At Nov 2021

This blog discusses the different methods to count the total numbers of nodes in a complete binary tree. Read the whole blog for the detailed solution.... Keep reading ..

Iterative Approach to Check if a Binary Tree is BST or Not

By Saksham Gupta

● Published At Jan 2022

This blog will discuss how we can solve a famous interview question check if a binary tree is BST or not. We will see how we can solve it iteratively.
... Keep reading ..

Print all root-to-leaf paths with maximum count of even nodes

By Saksham Gupta

● Published At Jan 2022

This blog will discuss how we can solve one of the most asked questions based on tree traversals, i.e., Print all root-to-leaf paths with maximum count of even nodes.
... Keep reading ..

Count nodes having the highest value in the path from the root to itself in a Binary Tree

By Saloni Singhal

● Published At Dec 2021

This article covers different approaches and implementations in C++ for counting nodes having the highest value in the path from the root to itself in the Binary Tree.
... Keep reading ..

Check if a binary tree contains node values are in strictly increasing and decreasing order at even and odd levels

By Shreya Deep

● Published At Nov 2021

In this article, we will discuss how to check if a binary tree contains node values in strictly increasing and decreasing order at even and odd levels... Keep reading ..

Maximum Level Sum in N-ary Tree

By Riya

● Published At Feb 2022

This article will discuss the problem "Maximum Level Sum in N-ary Tree", the solution approach for this problem, its C++ implementation, and its time and space complexity.... Keep reading ..

Print all K-sum levels in a Binary Tree

By Yukti Kumari

● Published At Dec 2021

This article explains the solution to the problem to print all K-sum levels in a binary tree.
... Keep reading ..

Diamond Tree

By Aman Chourasiya

● Published At Dec 2021

In this blog, we will discuss a constructive coding problem based on binary trees. We will see how to solve the problem and print the tree using level-order traversal.... Keep reading ..

Palindromic Levels Of a Binary Tree

By Saksham Gupta

● Published At Jan 2022

In this blog, we will see a variation of the classic level order traversal problem and discuss the palindromic levels of a binary tree. ... Keep reading ..

Convert the Given binary Tree into a Symmetric Tree by adding a minimum number of nodes

By Vaibhav Agarwal

● Published At Jan 2022

This article will discuss the problem of converting the given binary tree into a symmetric tree by adding a minimum number of nodes.
... Keep reading ..

Maximum Width of a Binary Tree with a Null Value

By Rhythm Jain

● Published At Dec 2021

This article discusses the problem of finding the Maximum width of a Binary Tree with a null value.... Keep reading ..

Check if binary tree contains a balanced BST of size k

By Shreya Deep

● Published At Dec 2021

In this article, we will learn how to check if binary tree contains a balanced BST of size k... Keep reading ..

Count pairs of leaf nodes in a Binary Tree which are at most K distance apart

By Aditya Narayan Joardar

● Published At Dec 2021

This article discusses how to count pairs of leaf nodes in a Binary Tree which are at most K distance apart.... Keep reading ..

Print Cousins of A Given Node in a Binary Tree

By Mandla Dharani

● Published At Apr 2022

This blog discusses the idea, code implementation of Print Cousins of a given node in a Binary Tree.
... Keep reading ..

The Maximum Cost of Splitting Binary Tree into Two Halves

By Ujjawal Gupta

● Published At Jan 2022

In this blog, we will learn to solve a problem based on a Binary tree. After splitting the binary tree into two halves, we will find its maximum cost.... Keep reading ..

Smallest subtree with all the deepest nodes

By Shreya Deep

● Published At Dec 2021

In this article, we will learn how to find the root of the smallest subtree with all the deepest nodes... Keep reading ..

Check if all the Nodes in a Binary Tree having common values are at least D distance apart

By Aman Chourasiya

● Published At Dec 2021

In this blog, we will take up a problem based on binary trees and longest distance in a binary tree. We will modify post order traversal of a binary tree to find the longest distance in a tree.... Keep reading ..

Find maximum GCD value from root to leaf in a Binary Tree

By Shreya Deep

● Published At Dec 2021

In this article, we will learn how to find the maximum GCD value from root to leaf in a binary tree... Keep reading ..

Modify Binary Tree By Replacing Each Node With The Product Of All Remaining Nodes

By Rhythm Jain

● Published At Dec 2021

This article discusses the problem of modifying Binary Tree By Replacing Each Node With The Product Of All Remaining Nodes... Keep reading ..

Find K smallest leaf nodes from a given Binary Tree

By Debarati Ghatak

● Published At Nov 2021

In this blog, we will discuss finding the K smallest leaf nodes from a given Binary Tree. Read further to learn the solution in detail.... Keep reading ..

Minimize the sum of node values by filling a given empty Tree such that each node is GCD of its children

By Amarjeet Kumar

● Published At May 2022

This article will discuss how to fill the given empty Tree with nodes that are GCD of their offspring to minimize the total of node values.... Keep reading ..

Minimum value to be added at every Binary Tree level to make the sum at all levels equal

By Sandeep kamila

● Published At Mar 2022

In this article, we will learn to calculate the minimum value needed to be added at every level in a binary tree to equal the sum at all levels with its C++ code.... Keep reading ..

How to remove subtrees containing zeroes in a binary tree

By Gorakhnath yadav

● Published At Nov 2021

In this blog, we will discuss how we can remove subtrees containing zeroes in a binary tree. Please read the blog to learn it in detail.... Keep reading ..

Check whether every node of the binary tree has a value K on itself or its any immediate neighbours

By Debarati Ghatak

● Published At Dec 2021

This blog will discuss the problem of checking whether every node of the binary tree has a value k on itself or any of its neighbours. Read this blog further to understand the solution along with implementation in detail.... Keep reading ..

Maximum Absolute difference between any two levels of binary Tree

By Vaibhav Agarwal

● Published At Jan 2022

In this article, we will discuss the problem to find the maximum absolute difference between any two levels of binary tree
... Keep reading ..

How to find the maximum value of Bitwise AND from root to leaf in a Binary tree?

By Sandeep kamila

● Published At Nov 2021

This article covers the implementation of the maximum value of Bitwise AND from root to leaf node.... Keep reading ..

Print the longest path from the root to leaf in a Binary tree

By Mehak Goel

● Published At Feb 2022

This article covers the implementation of the longest path from the root to leaf in a Binary tree with a complete explanation and its C++ code.... Keep reading ..

Sum of Leaf Node at each Horizontal Level of Binary Tree

By Yogesh Kumar

● Published At Nov 2021

In this blog, we will find the sum of leaf nodes at every horizontal level of the Binary Tree. ... Keep reading ..

Check if a Binary Tree is an Even-Odd Tree or Not

By Riya

● Published At Feb 2022

This article will discuss the problem "Check if a binary tree is an even-odd tree or not", two approaches to solve this problem, their C++ implementation, and time and space complexity.... Keep reading ..

Print alternate nodes from all levels of a Binary Tree

By Apoorv

● Published At Feb 2022

This article will discuss the solution of the problem “Print alternate nodes from all levels of a Binary Tree” along with the discussion on time complexity and space complexity for the solution... Keep reading ..

Print all possible N-nodes Full Binary Trees

By Aman Chourasiya

● Published At Dec 2021

In this blog, we will take up a coding problem based on full binary trees. We will learn to use dynamic programming(with memorization) and hashing to solve the challenge.... Keep reading ..

Find the Maximum Path Sum Between Two Leaves of A Binary Tree

By Deeksha Sharma

● Published At Jan 2022

In this blog, we will discuss a quite popular interview problem: finding the maximum path sum between two leaves of a binary tree. Here we will discuss two approaches for solving this problem.... Keep reading ..

Find distance between two nodes of a Binary Tree

By Raksha jain

● Published At Jan 2022

The blog discusses how to "find the distance between two nodes of a Binary Tree." We'll discuss an approach to solve the problem, time and space complexity.... Keep reading ..

Mirror tree from the given binary tree

By ankit mittal

● Published At Jan 2022

In this article, we will create a mirror tree from the given binary tree. This is a common tree question that can be solved with the recursive algorithm.
... Keep reading ..

Maximum width of a binary tree

By Alisha Chhabra

● Published At Dec 2021

In this article, we will be finding the maximum width of a binary tree using Level-order traversal.
... Keep reading ..

Heavy-light Decomposition (HLD)

By Shreya Deep

● Published At Feb 2022

In this article, I’ll introduce you to heavy-light decomposition.... Keep reading ..