Binary Tree
A binary tree is another example of a data structure similar to a linked list, but instead of each node pointing to the very next node linearly, each node points to the two nodes, hence making this an example of a non-linear data structure. The tree structure is a way of representing the hierarchical nature of a structure in a graphical form. In the Abstract data type of trees, the order of the elements is not essential. If we need ordering information, linear data structures like a linked list, stacks, queues, etc., can be used.
Binary Tree using dstructure library in Python
By Aman kumar Chourasiya
● Published At Jan 2022
In this blog, we will discuss the binary tree data structure in python which is implemented in the dstructure library. We will also see various pre-defined functions in the library.... Keep reading ..
Types of Binary trees
By Malay Gain
● Published At Oct 2021
There are a few types of Binary Trees commonly known. In this article, we will discuss them.... Keep reading ..
Create a Balanced Binary Tree using leaf Nodes of a Binary Tree without using Extra Space
By Riya
● Published At Feb 2022
This article will discuss how to create a balanced binary tree using leaf nodes of a binary tree without using extra space, its C++ implementation, and its time and space complexity.... Keep reading ..
N-Ary Trees
● Published At Nov 2021
Operations on Binary Tree
A binary tree is one of the most important data structures in real-world applications. So knowing the binary tree inside out is essential to make it into reputed product-based companies. Search, Insert and delete are 3 fundamental operations to know about. Not just that, it's equally important to know and understand the complexity analysis of the Binary tree.
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 ..
The Binary Lifting Technique
By Akshat Chaturvedi
● Published At Nov 2021
In this blog post, we’ll learn one interesting technique Binary Lifting, which then we’ll use to improve the efficiency of the LCA problem.... Keep reading ..
Construct a Complete Binary Tree from its Linked List Representation
By Debarati Ghatak
● Published At Nov 2021
In this blog, we will discuss how to Construct a Complete Binary Tree from its Linked List Representation.... Keep reading ..
Convert a generic tree (n-ary tree) to binary tree
By Shreya Deep
● Published At Dec 2021
In this article, we will learn how to convert a generic tree to a binary tree... Keep reading ..
Traversals
Traversals are usually the very first operation performed on any data structure. From searching, inserting, deleting a specific element in a data structure, every operation usually requires data structure traversal. And time complexity of any algorithm majorly depends on the number of traversals made in the algorithm. So it's always preferred to make the least possible traversals or traversing in the most efficient way possible.
Traversal in Binary Tree
By Shubham Agarwal
● Published At Apr 2022
The blog covers descriptions of various types of Depth binary tree traversal. The blog also contains multiple kinds of Binary Trees. ... Keep reading ..
How to Print a Binary Tree in Vertical Order | Part-1
● Published At Apr 2022
This blog discusses the basic methods to print a binary tree in vertical order. Read further to see the detailed solution.... Keep reading ..
How to Print a Binary Tree in Vertical Order | Part-2
● Published At Apr 2022
This blog discusses the map and preorder traversal-based methods to print a binary tree in vertical order. Read further to see the detailed solution. ... Keep reading ..
How to Print a Binary Tree in Vertical Order | Part-3
● Published At Apr 2022
This blog discusses the level order traversal-based method to print a binary tree in vertical order. Read further to see the detailed solution. ... Keep reading ..
Double Order Traversal of a Binary Tree
By Nishant Rana
● Published At Feb 2022
Diagonal Traversal of Binary Tree (Recursive and Iterative)
By Raksha Jain
● Published At Apr 2022
The blog discusses in detail about Diagonal Traversal of Binary Trees. We'll discuss many approaches to solve the problem, time and space complexity for each method. ... Keep reading ..
Specific Level Order Traversal of Binary Tree
By Apoorv
● Published At Feb 2022
This article will discuss the solution to print a binary tree in a specific Level Order Traversal mentioned in the problem statement along with the solution will explore its time complexity and space complexity ... Keep reading ..
Iterative Postorder Traversal of Binary tree
By Alisha Chhabra
● Published At Oct 2021
In this article, we’ll look at how one can perform the Postorder Traversal of a Binary tree using the Iterative approach.... Keep reading ..
Iterative Postorder Traversal of a binary tree | Part-2
By Alisha Chhabra
● Published At Oct 2021
In this article, we will be looking at the alternative approach for traversing the tree using Iterative Postorder Traversal with a single stack.... Keep reading ..
Iterative Preorder Traversal of Binary tree
By Alisha Chhabra
● Published At Oct 2021
In this article, we’ll look at how one can perform the Preorder Traversal of a Binary tree using the Iterative approach.... Keep reading ..
Clockwise Triangular Traversal of a Binary Tree
By Firdausia Fatima
● Published At Jan 2022
In this blog, we’ll see how to do clockwise triangular traversal of a binary tree.... Keep reading ..
Level Order Traversal Of  A Binary Tree
By Deeksha
● Published At Oct 2021
In this blog, we are going to learn about the level order traversal of a binary tree. Level Order Traversal of a binary tree is also known as Breadth-First Search.... Keep reading ..
ZigZag Traversal of Binary Tree
By Raksha Jain
● Published At Jan 2022
The blog discusses in detail about ZigZag traversal of Binary Tree. We'll discuss many approaches to solve the problem and time and space complexity for each method." ... Keep reading ..
Boundary Traversal Of Binary Tree (Recursive and Iterative)
By Deeksha
● Published At Oct 2021
In this blog, we will discuss a new way of traversing a binary tree known as the boundary traversal of a binary tree.... Keep reading ..
Iterative Inorder Traversal of Binary tree
By Yogesh Kumar
● Published At Oct 2021
This article will discuss the Inorder Traversal of a binary tree without recursion, its basic concepts, algorithms, and implementation in Java.... Keep reading ..
Morris Traversal for Inorder
By Mehak Goel
● Published At Oct 2021
In this blog, we will be learning about morris traversal for inorder in a binary tree using the C++ programming language.... Keep reading ..
Print all Prime Levels of a Binary Tree
● Published At Nov 2021
This article discusses the problem of how to print all prime levels of a given binary tree.... Keep reading ..
Bottom-left to upward-right Traversal in a Binary Tree
By Yukti Kumari
● Published At Nov 2021
Check if given inorder and preorder traversals are valid for any Binary Tree without building the tree
By Debarati Ghatak
● Published At Dec 2021
This blog will discuss how to check if given inorder and preorder traversals are valid for any Binary Tree without building the tree.... Keep reading ..
Construct A Perfect Binary Tree From A Preorder Traversal
By Harsh Goyal
● Published At Dec 2021
This article will discuss the Construct a perfect binary tree from a preorder traversal and will learn about the preorder traversal. ... Keep reading ..
Inorder Successor in Binary Tree
By Deeksha
● Published At Oct 2021
In this blog, we will be discussing a concept frequently asked in all interviews i.e Inorder Successor Of Binary Tree. We will be discussing two approaches to this problem.... Keep reading ..
Views
There are four types of views in a Binary Tree. The views are Left view, Right view, Bottom view, and Top view. In the Left view, we need to print all the nodes that are visible if we see the tree from the left side. In the Right view, we need to print all the nodes that are visible if we see the tree from the reft side. In the top view, we need to print all the nodes that are visible if we see the tree from the top. In the bottom view, we need to print all the nodes that are visible if we see the tree from the bottom.
Right View of a Binary Tree
By Rubleen Kaur
● Published At Oct 2021
This article is based on the problem of printing the right view of any given binary tree. The two main approaches and the Java code have been discussed in the blog.... Keep reading ..
Left View of a Binary Tree in Java
By Rubleen Kaur
● Published At Oct 2021
The article is based on the problem of printing nodes of the tree visible from the left view. We will discuss various approaches to the problem. ... Keep reading ..
Top view of a binary tree | Part-1
● Published At Jan 2022
In this blog discusses the basic method we can use to print the top view of a binary tree. Read further to know more. ... Keep reading ..
Top View of A Binary Tree | Part-2
● Published At Apr 2022
This blog discusses the maximum distance-based method to print the top view of a binary tree. Read further to know more ... Keep reading ..
Bottom View of A Binary Tree
By Mandla Dharani
● Published At Apr 2022
In this blog, we discussed the implementation of the bottom view of a binary tree using queue and Hash map. The entire blog is written in C++. ... Keep reading ..
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
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
● 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
● 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
● 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