Problems

Binary Search 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 the Binary Tree such as searching for a key in a Binary Search Tree, Diametre of a Binary Search Tree, etc.
Let us explore more problems to expertise in the same!

Lowest Common Ancestor in a Binary Search Tree

By aniket verma

● Published At Oct 2021

This article will brief you on finding the Lowest Common Ancestor in a Binary Search Tree.
... Keep reading ..

Finding inorder predecessor of a node in a Binary Search Tree

By Akshat Chaturvedi

● Published At Nov 2021

In this blog, we’ll see what an inorder predecessor of a node in a binary search tree is and how we can find it using a simple recursive approach.... Keep reading ..

Finding Inorder Successor of a node in a Binary Search Tree

By Akshat Chaturvedi

● Published At Nov 2021

In this blog, we will learn what an inorder successor of a given key in Binary Search Tree is and how to code it in C++.... Keep reading ..

Number of Binary Search Trees of height H consisting of H+1 nodes

By Firdausia Fatima

● Published At Jan 2022

In this blog, we’ll see how maths can ease our work by solving an exciting problem, the Number of Binary Search Trees of height H consisting of H+1 nodes.... Keep reading ..

Range Sum of BST

By Alisha Chhabra

● Published At Oct 2021

In this article, we’ll calculate the Range Sum of BST using the recursive approach. ... Keep reading ..

Flatten a Binary Search Tree to Convert the Tree into a Wave List in Place Only

By Saksham Gupta

● Published At Jan 2022

In this blog, we will discuss how we can solve the problem ‘Flatten a Binary Search Tree to convert the tree into a wave list in place only ’ in the most efficient way possible.
... Keep reading ..

Flattening BST in Sorted List

By Deepanshu Dhingra

● Published At Jan 2022

A complete walkthrough of the problem - Flattening BST in Sorted List. This article will discuss the approaches to solve the problem along with the discussion for Space and Time Complexities.
... Keep reading ..

Row with the maximum number of 1’s

By Sandeep kamila

● Published At Nov 2021

This article covers different approaches and implementations of the problem row with the maximum number of 1’s in C++.... Keep reading ..

Create a wave array from the given Binary Search Tree

By Ishita Chawla

● Published At Dec 2021

This blog will discuss the problem to create a wave array from the given Binary Search Tree.
... Keep reading ..

Sum of all nodes with smaller values at a distance ‘K’ from the given node in BST

By Ujjawal Gupta

● Published At Jan 2022

In this blog, we will learn to solve a problem based on a Binary search tree.
... Keep reading ..

Median of All Nodes from a Given Range in a BST

By Firdausia Fatima

● Published At Jan 2022

In this blog, we’ll be solving a tree traversal problem, the median of all nodes from a given range in a BST.... Keep reading ..

Print All Odd Nodes Of Binary Search Tree

By Harsh Goyal

● Published At Dec 2021

This article will discuss the print all the odd nodes of the binary search tree problem and the efficient way to solve this problem.
... Keep reading ..

Print all the even nodes of a Binary Search Tree

By Sandeep kamila

● Published At Dec 2021

This article covers the approach of printing all the even nodes of a Binary search tree and its code in C++.... Keep reading ..

Node with the maximum value in a Binary Search Tree

By Sandeep kamila

● Published At Dec 2021

This article covers the implementation of finding the node with maximum value in a binary search tree with an explanation and its C++ code.
... Keep reading ..

Sum and the Product of minimum and maximum elements of a Binary Search Tree

By Sandeep kamila

● Published At Dec 2021

This article covers the approach and implementation of finding the sum and the product of a Binary search tree’s minimum and maximum elements with its C++ code.... Keep reading ..

Find Closest Smaller Value For Every Element In Array

By Harsh Goyal

● Published At Dec 2021

This article will discuss to find the closest smaller value for every element in the array and various ways to solve this problem... Keep reading ..

Find Closest Value For Every Element In Array

By Harsh Goyal

● Published At Dec 2021

This article will discuss the find the closest value for every element in the array problem and various ways to solve this problem.
... Keep reading ..

Find the median of BST in O(N) time and O(1) space.

By Pradipta Choudhury

● Published At Oct 2021

We are given a BST, and we need to find the median of BST in O(N) time complexity and O(1) space.
... Keep reading ..

Kth Largest Element BST

By Harsh Goyal

● Published At Nov 2021

This article will discuss the approach to find out Kth largest element in a Binary Search Tree starting from the brute force approach to the efficient approach.... Keep reading ..

Largest BST subtree in the given Binary Tree

By Nishant Rana

● Published At Oct 2021

This blog will cover the question of finding the Largest BST subtree in the given Binary Tree and optimizing the approach from O(N *N) to O(N).
... Keep reading ..

Count pairs violating BST property

By Urwashi Priya

● Published At Dec 2021

This article will brief you on how to Count pairs violating BST property.
... Keep reading ..

Count BST Nodes that lie in a given Range

By Sneha Mallik

● Published At Oct 2021

This blog covers counting BST nodes that lie in a given range and covers the basic concepts, code and algorithm of binary search trees.
... Keep reading ..

Count of Smaller Numbers After Self

By Soumya Agrawal

● Published At Oct 2021

In this problem, we will aim to find the count of smaller numbers.
... Keep reading ..

Convert a Binary Tree to BST by Left-Shifting digits of Node Values

By Riya

● Published At Feb 2022

This article will discuss the problem “Convert a Binary Tree to BST by Left-Shifting digits of Node Values”, the solution approach to this problem, its C++ implementation, and its time and space complexity.... Keep reading ..

Print nodes of a Binary Search Tree in Top Level Order and Reversed Bottom Level Order alternately

By Gaurish Anand

● Published At Dec 2021

You are given a Binary Search Tree (BST) where you have to print the nodes from the 1st level, then Nth level (in reverse order), 2nd level, (N-1)th level, and so on.... Keep reading ..

Count permutations of the given array that generates the same Binary Search Tree (BST)

By Apoorv

● Published At Feb 2022

This article will discuss the solution to count permutations of the given array that generates the same Binary search tree along with the solution blog will also discuss the time complexity and space complexity for the solution to count permutations... Keep reading ..

Traverse a BST in a min-max manner

By Gaurish Anand

● Published At Dec 2021

You are given a Binary Search Tree (BST). You have to traverse the tree in a min-max manner, i.e., first, travel the minimum of the tree, then maximum and then 2nd minimum, 2nd maximum, and so on.... Keep reading ..

Count the Number of Binary Search Trees present in a Binary Tree

By Ayush Prakash

● Published At Feb 2022

In this blog, we’ll discuss an interesting tree problem: Count the number of Binary search trees in a binary tree. We are also going to discuss the time and space complexities of the approaches covered.
... Keep reading ..

Check if a triplet with given sum exists in BST

By Aditya Narayan Joardar

● Published At Dec 2021

This article discusses how to check if a triplet with a given sum exists in BST or not, using examples and explanations.... Keep reading ..

Maximum height of the binary search tree created from the given array

By Nishant Rana

● Published At Feb 2022

This blog will cover the question to find the maximum height of the Binary Search Tree created from the given array discuss its Time and Space complexity.
... Keep reading ..

Implementing a BST where every node stores the maximum number of nodes in the path till any leaf

By Ayush Prakash

● Published At Feb 2022

In this blog, we will discuss an interesting tree problem: Implementing a binary search tree where every node stores the maximum number of nodes in the path till any leaf. We will also discuss the time and space complexity of the approaches covered.... Keep reading ..

Find the preorder successor of all the nodes in a BST

By Gaurish Anand

● Published At Dec 2021

You are given a Binary Search Tree (BST), and you have to find the pre-order successor of all the nodes.... Keep reading ..

Check If the Two Binary Search Trees are Identical or Not

By Rhythm Jain

● Published At Dec 2021

This article discusses the problem of checking Whether the Two Binary Search Trees are Identical or Not... Keep reading ..

Number of pairs with a given sum in a Binary Search Tree

By Vibhor Bhatnagar

● Published At Dec 2021

This article will discuss the problem to find the number of pairs with a given sum in a Binary Search Tree.... Keep reading ..

Print all pairs from two BSTs whose sum is greater than the given value

By Vibhor Bhatnagar

● Published At Dec 2021

This article will discuss the problem print all pairs from two BSTs whose sum is greater than the given value.... Keep reading ..

Split a BST into two balanced BSTs based on a value V

By Apoorv

● Published At Feb 2022

This article will discuss the solution of the problem statement “Split a BST into two balanced BSTs based on a value V” along with solution this blog will also discuss the time and space complexity for the solution... Keep reading ..

Find the minimum absolute difference in two different BST

By Urwashi Priya

● Published At Dec 2021

This article will brief you on how to Find the minimum absolute difference in two different BST.
... Keep reading ..

Check for Nodes from given two BSTs with a sum equal to X

By Urwashi Priya

● Published At Dec 2021

This article will brief you on how to Check for Nodes from given two BSTs with a sum equal to X
... Keep reading ..

Remove BST nodes having a value in the given range.

By Vaibhav Agarwal

● Published At Dec 2021

In this article, we will discuss the problem to remove BST nodes having a value in the given range. ... Keep reading ..

Find the maximum count of duplicate nodes in a Binary Search Tree

By Vibhor Bhatnagar

● Published At Dec 2021

This article will discuss the problem find the maximum count of duplicate nodes in a binary search tree.... Keep reading ..

Kth Smallest Element in a Perfect Binary Search Tree

By Debarati Ghatak

● Published At Nov 2021

In this blog, we will discuss finding the Kth smallest Element in a Perfect Binary Search Tree. ... Keep reading ..

Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order

By Ayush Prakash

● Published At Feb 2022

This blog will discuss a tree problem: “Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order”. We will also analyse the time and space complexity of all the approaches discussed.
... Keep reading ..

Check if two given key sequences construct the same BSTs

By Apoorv

● Published At Feb 2022

This article will discuss the solution to check if two given key sequences construct the same BSTs or not along with; the solution blog also focuses on time and space complexity for the solution to check whether two given key sequences construct the ... Keep reading ..

Convert a Sorted Linked List to Balanced BST

By Mehak Goel

● Published At Nov 2021

In this blog, we will learn to convert a sorted Linked List to Balanced BST (Binary Search Tree) in the C++ programming language.
... Keep reading ..

Number of BSTs

By Pranav Gautam

● Published At Nov 2021

Learn to find the unique BSTs possible for a given number ‘N’. Learn the application of Catalan numbers.... Keep reading ..

Why Binary Heap is Better than Binary Search Tree (BST) for Priority Queues

By Reet Maggo

● Published At Apr 2022

This article will discuss why Binary Heap is better than Binary Search Tree for Priority Queues by comparing their working.... Keep reading ..