×
Home Discussions Write at Opengenus IQ
×
  • DSA Cheatsheet
  • HOME
  • Track your progress
  • Deep Learning (FREE)
  • Join our Internship 🎓
  • RANDOM
  • One Liner

Problems on Binary Tree

Binary Tree is one of the most common data structures that are used in solutions of various Interview and Competitive Programming problems. Practice problems on Binary Tree.

Problems on Binary Tree

Serialization and Deserialization of Binary Tree

We have presented the process of Serialization and Deserialization of Binary Tree where we convert a Binary Tree into a compress form which can be saved in a file and retrieved back.

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Convert a Binary Tree to a Skewed Binary Tree

We have presented the algorithm to Change a Binary Tree to a Skewed Binary Tree (both Increasing Skewed Binary Tree and Decreasing Skewed Binary Tree).

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Check if a Binary Tree is skewed or not

We have presented the algorithm to check if a given Binary Tree is skewed or not (can be left or right skewed Binary Tree).

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Introduction to Skewed Binary Tree

A binary tree can be called a skewed binary tree if all nodes have one child or no child at all. There are two types: left and right skewed.

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Find ancestors of a given node in a binary tree (Recursive + Iterative)

Understand how to find ancestors of a given node in a binary tree recursively and iteratively in linear time O(N).

Akshay Atam
Problems on Binary Tree

Find nodes which are at a distance k from root in a Binary Tree

We are given the root of a tree, and an integer k. We need to print all the nodes which are a distance k from the root.

Amruta U. Koshe Amruta U. Koshe
Problems on Binary Tree

Find ancestors of a node in Binary tree (Recursive)

In this problem, we are given a binary tree and a key k. We need to find out all the ancestors of node k. We have used a recursive approach.

Amruta U. Koshe Amruta U. Koshe
Algorithms

Finding nodes at distance K from a given node

We have discussed the approach to find out the nodes at k distance from the given node. There are two approaches: one using Breadth First Traversal and other using Percolate Distance.

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Check if a Binary Tree has duplicate values

Given a Binary Tree, we will develop an algorithm to check if it has duplicate values. This can be done in linear time O(N) where there are N elements in the Binary Tree.

Manasvi Singh
Problems on Binary Tree

Find if a given Binary Tree is a Sub-Tree of another Binary Tree

A sub-tree is a tree itself that is the subset of a bigger binary tree. A subtree of a node means that it is the child of that node. In this article, we will find out different ways to find out if a given binary tree is a sub-tree of another binary tree.

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Convert Binary Tree to Threaded Binary Tree

We will focus on different approaches on how to convert a normal binary tree into a threaded binary tree. We will convert our binary tree to single threaded binary tree with right pointers pointing to inorder successor (if it exists).

Hrithik Shrivastava Hrithik Shrivastava
Problems on Binary Tree

Check if a Binary Tree is Balanced by Height

In this article, we have explored the algorithm to check if a Binary Tree is balanced by height or not.

Srishti Guleria Srishti Guleria
Problems on Binary Tree

Designing a Binary Search Tree with no NULLs

A Binary Search Tree (BST) is usually implemented using NULLs in C or C++. This article explores an alternative approach of using placeholder nodes. Here the Binary Search Tree will be implemented in C++.

Rohit Topi
Problems on Binary Tree

Finding Diameter of a Tree using DFS

In this article, we will be discussing how to find the diameter of a tree or graph using Depth First Search (DFS).

Hrithik Shrivastava Hrithik Shrivastava
Problems on Binary Tree

Diameter of a Binary Tree

In this problem, we are given input as the reference to the root of a binary tree. We need to find the diameter of the tree. We find the diameter using recursion and Depth First Search (DFS).

Amruta U. Koshe Amruta U. Koshe
Problems on Binary Tree

Algorithm to find Level of each node from root node

In this article we will be discussing on how to find the level of each node in a graph, the algorithm that we will be using to find the level of each node is breadth first search.

Hrithik Shrivastava Hrithik Shrivastava
Problems on Binary Tree

Counting subtrees where nodes sum to a specific value

We will learn about counting the subtrees in a binary tree whose nodes sum to a given value. We will be trying different methods to solve our problem We will solve it in O(N) time complexity and O(H) space complexity where N is number of nodes and H is the height of the tree.

Rashmitha
Problems on Binary Tree

Find number of Universal Value subtrees in a Binary Tree

In this article, we will be working on finding number of subtrees whose nodes have same value, called universal value subtree or simply univalue subtree.

Rashmitha
Problems on Binary Tree

Converting a Sorted Array to Binary Tree

Sorted array is converted to Binary Search Tree for faster search operations and querying. In this article we'll learn to convert any sorted array to binary search tree.

Sahil Silare Sahil Silare
Data Structures

Implementing a Binary Search Tree (BST) in C++

In this article, we have explained the idea of implementing Binary Search Tree (BST) from scratch in C++ including all basic operations like insertion, deletion and traversal.

Sahil Silare Sahil Silare
Problems on Binary Tree

Implementing Binary tree in C++

In this article, we have explored how to implement Binary Tree Data Structure in C++ including all different operations like traversing, inserting and deleting. We have used Object Oriented Programming (OOP) concepts.

Ayush Sonare
Algorithms

Bidirectional Search

Bidirectional Search is Graph Search Algorithm where two graph traversals (BFS) take place at the same time and is used to find the shortest distance between a fixed start vertex and end vertex. It is a faster approach, reduces the time required for traversing the graph.

Sargam Monga Sargam Monga
Problems on Binary Tree

Find height or depth of a binary tree

Length of the longest path from the root node to a leaf node is the height of the binary tree. We find it in linear time using a recursive algorithm

Akshay Gopani Akshay Gopani
Problems on Binary Tree

Largest Independent Set in Binary Tree

In this article, we solve the Largest Independent Set in Binary Tree problem using Dynamic Programming and use an augmented binary tree to achieve this.

Parth Maniyar Parth Maniyar
Problems on Binary Tree

Sum of k smallest elements in Binary Search Tree

Given a binary search tree and a integer k our task is to find out sum of all the elements which is less or equal to the k th smallest element

Parth Maniyar Parth Maniyar
OpenGenus IQ © 2025 All rights reserved â„¢
Contact - Email: team@opengenus.org
Primary Address: JR Shinjuku Miraina Tower, Tokyo, Shinjuku 160-0022, JP
Office #2: Commercial Complex D4, Delhi, Delhi 110017, IN
Top Posts LinkedIn Twitter
Android App
Apply for Internship