'Coding has over 700 languages', '67% of programming jobs aren’t in the technology industry', 'Coding is behind almost everything that is powered by electricity'
Last updated: Aug 2, 2022

Binary Search Tree

A binary search tree is a specific type of binary tree that is either empty, or each node in the tree contains a key, and all keys in the left subtree are less (numerically or alphabetically) than the identifier in the root node; all keys in the right subtree are greater than the identifier in the root node and the left and right subtrees are also binary search trees.
Splay Tree in Data Structure MEDIUM
Splay Tree is a self-adjusting binary search tree that uses splaying operation and improves the usage when the recently accessed element is to be reaccessed.
Inbuilt Binary Search in Different Languages EASY
This article will discuss binary search and inbuilt binary search functions in different languages like C++, java.
Author Riya
0 upvotes
Self Balancing Binary Search Trees
In this article, we will be covering an exciting topic Self Balancing Binary Search Trees.
Implementing Forward Iterator in BST
This article will discuss the low-level design of BST iterator which has a lot of functions like returning the current pointer in BST, next pointer in BST, and isend() function, which tells if there is a node present at the right of the current node or not in BST
Implementing Backward Iterator in BST
This article will discuss how to implement a backward iterator in BST, its C++ implementation, and its time and space complexity.
Author Riya
1 upvote
What is Optimal Binary Search Tree? EASY
In this blog, we will learn about What is Optimal Binary Search Tree. We will understand its core concepts, its usage, advantages and disadvantages, and much more for better understanding.
Construct BST from the given Pre-Order Traversal
You are given a pre-order traversal of a BST. Construct the BST using this pre-order traversal array.
Construct a BST from given Postorder Traversal using Stack
This article discusses how to construct a BST from given postorder traversal using Stack.
Construct BST from its given level order traversal MEDIUM
In this blog, we will discuss an interesting DSA problem which involves two crucial topics - Binary Search Trees and Level Order Traversals.
Construct all possible BSTs for keys 1 to N HARD
Binary Search Tree is an important data structure from an interview perspective. In this article, we will learn to construct all possible BSTs for keys 1 to N.
Insertion in Binary Search Tree(BST) EASY
One of the fundamental operations of the Binary Search Tree is to insert node binary search trees.
Insert a node in Binary Search Tree Iteratively MEDIUM
In this article, we will discuss the iterative insertion technique of a node in a binary search tree with help of examples along with its implementation in C++.
Insertion in Threaded Binary Search Tree MEDIUM
In this article, you will learn about Insertion in Threaded Binary Search Trees and code implementation.
Deletion in Binary Search Tree MEDIUM
In this blog, we are going to discuss an important concept i.e., deletion in Binary Search Tree and its implementation in java and c++.
Binary Search Tree | Iterative Delete MEDIUM
In this article, we will discuss the solution to delete a node iteratively in the binary search tree, along with its time complexity and space complexity.
Searching in BST MEDIUM
This article will discuss a coding problem related to binary search trees in which we have to search for key in our binary search tree. We will discuss the space and time complexities of the approach as well
Author Harsh
0 upvotes
Merge two balanced BSTs MEDIUM
This article will explain the coding problem in which we have to merge two balanced BSTs into one Balanced BST.
Author Harsh
0 upvotes
Convert a normal BST to a Balanced BST MEDIUM
This article will discuss a coding problem in which we will be given a normal BST and we have to convert this normal BST to a balanced BST.
Author Harsh
0 upvotes
Merge two BSTs with limited extra space MEDIUM
This blog will explain a coding problem related to BSTs in which we have to merge two BSTs with limited extra space
Author Harsh
0 upvotes
Binary Search Tree to greater sum tree MEDIUM
This blog discusses a Data Structures problem involving Binary Search Trees and reverse inorder traversal - two of the most popular topics in Data Structures and Algorithms.
Lowest Common Ancestor in a Binary Search Tree
This article will brief you on finding the Lowest Common Ancestor in a Binary Search Tree.
Finding Inorder Predecessor of a Node in a Binary Search Tree HARD
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.
Inorder Successor in BST (Binary Search Tree) MEDIUM
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++.
Find the second largest element in BST EASY
In this article, we will learn how to find the second largest element in binary search tree using reverse inorder traversal along with the algorithm and implementation.
Find the Largest Number in BST which is Less Than or Equal to N EASY
In this blog, we will find the largest number in BST which is less than or equal to N along with its code, algorithm and example.
Number of Binary Search Trees of Height H Consisting of H+1 Nodes
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.
Range Sum of BST MEDIUM
In this article, we’ll calculate the Range Sum of BST using the recursive approach.
Check if an array represents Inorder of BST EASY
In this blog, we have discussed a problem statement based on binary search tree called Check if Check if an array represents Inorder of BST
Author Shiva
0 upvotes
Check if two BSTs contain the same set of elements or not EASY
In this article, we will see the solution to a problem name Check if two BSTs have the same set of elements or not.
Flatten a Binary Search Tree to Convert the Tree into a Wave List in Place Only
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.
Flattening BST in Sorted List
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.
BST into a Min-Heap Without Using Array MEDIUM
This article will discuss a method to convert BST into a min heap. We will use a linked list and level order traversal approach to do the said conversion.
Binary Tree to BST Using an STL Set MEDIUM
This article will discuss the conversion of binary tree to BST using STL set. We will use STL set to do insertion, searching and deletion operation, in order to convert the binary tree to BST.
Implementing Decrease key in Binary Search Tree MEDIUM
A binary tree is a tree data structure having at most 2 children. This article will discuss how to implement decrease key in the binary search tree.
Row with the Maximum Number of 1’s MEDIUM
This article covers different approaches and implementations of the problem row with the maximum number of 1’s in C++.
Author Spider
0 upvotes
Sum of all Nodes with Smaller Values at a Distance ‘K’ from the given Node in BST
In this blog, we will learn to solve a problem based on a Binary search tree.
Median of All Nodes from a Given Range in a BST
In this blog, we’ll be solving a tree traversal problem, the median of all nodes from a given range in a BST.
Print All Odd Nodes Of Binary Search Tree
This article will discuss the print all the odd nodes of the binary search tree problem and the efficient way to solve this problem.
Print all the Even Nodes of a Binary Search Tree
This article covers the approach of printing all the even nodes of a Binary search tree and its code in C++.
Author Spider
0 upvotes
Check if the given sorted sub-sequence exists in BST MEDIUM
In this blog, we will check if the given sorted sub-sequence exists in BST.
Node with the Maximum Value in a Binary Search Tree
This article covers the implementation of finding the node with maximum value in a binary search tree with an explanation and its C++ code.
Author Spider
0 upvotes
Sum and the Product of Minimum and Maximum Elements of a Binary Search Tree
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.
Author Spider
0 upvotes
Find if a given Array can Represent Preorder Traversal of BST MEDIUM
This article incorporates information about how to find whether a given array can represent a preorder traversal of BST or not.
Find if the given array of size n can represent BST of n levels or not MEDIUM
In this article, we will solve a famous question on the BST: Find if the given array of size n can represent BST of n levels or not. This famous BST question has been asked in many interviews.
Find Closest Smaller Value For Every Element In Array MEDIUM
This article will discuss to find the closest smaller value for every element in the array and various ways to solve this problem along with the time and space complexity.
Find Closest Value For Every Element In Array MEDIUM
This article will discuss the find the closest value for every element in the array problem and various ways to solve this problem.
Find the Maximum Unique Element in Every Subarray of Size K HARD
This article discusses the problem of finding the maximum unique element in every subarray of size k, its solution approaches, its implementation, and time complexity.
Largest BST subtree in the given Binary Tree
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).
Count BST Nodes that Lie in a given Range MEDIUM
This blog covers counting BST nodes that lie in a given range and covers the basic concepts, code and algorithm of binary search trees.
Count of Smaller Numbers After Self
This blog will discuss the problem named Count of Smaller Numbers After Self.
Convert a Binary Tree to BST by Left-Shifting digits of Node Values MEDIUM
We will discuss the problem “Convert a Binary Tree to BST by Left-Shifting digits of Node Values”,its solution, C++ implementation, and its complexities.
Convert a BST to a Binary Tree such that the sum of all greater elements is added to every element MEDIUM
In this article, we will solve a famous question on the BST: convert a BST to a Binary Tree such that the sum of all greater elements is added to every element.
Print nodes of a Binary Search Tree in Top Level Order and Reversed Bottom Level Order Alternately
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.
Count Permutations of the given Array that Generates the Same Binary Search Tree (BST) MEDIUM
This article will discuss the solution to count permutations of the given array that generate the same Binary search tree, with it's time and space complexity.
Traverse a BST in a Min-Max Manner
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.
Count the Number of Binary Search Trees present in a Binary Tree MEDIUM
This blog will discuss the problem named Count the Number of Binary Search Trees present in a Binary Tree.
Check if a Triplet with given Sum Exists in BST MEDIUM
This article uses examples and explanations to check whether a triplet with the given sum exists in BST.
Check if each internal node of a BST has exactly one child MEDIUM
This article incorporates how to check if each internal node of a BST has exactly one child.
Minimum swap required to convert binary tree to binary search tree
In this article, we will discuss a very interesting problem: we have to calculate the minimum number of swaps required to convert the given binary tree into the binary search tree
Implementing a BST Where Every Node Stores the Maximum Number of Nodes in the Path till any Leaf
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.
Find the Preorder Successor of all the Nodes in a BST
You are given a Binary Search Tree (BST), and you have to find the pre-order successor of all the nodes.
Check If the Two Binary Search Trees are Identical or Not
This article discusses the problem of checking Whether the Two Binary Search Trees are Identical or Not
Split a BST into two balanced BSTs based on a value V
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
Remove BST nodes having a value in the given range.
In this article, we will discuss the problem to remove BST nodes having a value in the given range.
K’th Smallest Element in BST HARD
In this blog, we have discussed a problem statement based on a binary search tree called K’th smallest element in BST.
Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
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.
Check if two given key sequences construct the same BSTs MEDIUM
This article discusses the problem and the solution for checking if two given sequences contain the same binary search tree.
Check for Identical BSTs Without Building the Trees HARD
In this blog, we have discussed a problem statement based on a binary search tree called Check for identical BSTs without building the trees.
Number of BSTs
Learn to find the unique BSTs possible for a given number ‘N’. Learn the application of Catalan numbers.
Reverse a path in BST using queue
In this blog, we will discuss different approaches to reverse a path in a binary search tree using a queue. Then we will discuss their algorithms, implementations, and complexities analysis.
Node with minimum value in a BST MEDIUM
This blog will discuss a coding problem in which we have to find the node with the minimum value in BST. We will discuss the space and time complexities of the approach as well.
Author Harsh
0 upvotes
BST to a Tree with sum of all smaller keys MEDIUM
This article will discuss a coding problem in which we have to convert a given BST into a Tree under a condition.
Author Harsh
0 upvotes
Count the number of Nodes having Special Two-digit Numbers in BST HARD
In this article, we will discuss the code for finding the count of the nodes having special two-digit numbers in BST. We will be discussing the implementation in C++, Java and Python.
Add all greater values to every node in a given BST MEDIUM
In this article, we will discuss binary search tree data structure in brief, examples, approach, and how to add all greater values in Binary Search Tree to every node, time, and space complexity.
Calculate the Shortest Distance Between Two Nodes in BST MEDIUM
In this article, we will solve a famous question on the BST: Calculate the shortest distance between two nodes in BST. It is a famous interview question and has been asked in many interviews.
Find if the Given Array can represent Level Order Traversal of BST MEDIUM
In this article, we will solve a famous question on the BST: Find if the given array can represent the Level Order Traversal of BST or not. It has been asked in many interviews.
Remove BST Keys Outside the Given Range MEDIUM
We will solve the problem to remove BST keys outside the given range by using the divide and traverse technique.
Print BST Keys in the Given Valid Range MEDIUM
This article will discuss the problem to print BST keys in the given valid range. This article will discuss two approaches to solving this problem: inorder traversal and the Morris Traversal approach.
Replace every element with the least greater element on its right HARD
In this article, we will discuss binary search tree data structure in brief, and learn how to replace every element with the least greater element on its right with examples, approach, time, and space complexity.
Remove All Leaf Nodes from BST MEDIUM
In this blog, we will discuss the topic "Remove all leaf nodes from BST," including the sample examples, problem statement, approach, algorithm, implementation, and time and space complexity.
Find if there is a Triplet in a Balanced BST that Adds to 0 MEDIUM
This article will discuss the problem of "Find If There is a Triplet in a Balanced BST that Adds to 0. We will look at examples, algorithms, and implementation of problems.
Print the sum of k smallest elements in BST MEDIUM
In this blog, we will discuss the topic "Print the sum of k smallest elements in BST," including the examples, problem statement, approaches, algorithm, and implementation.
Count Pairs From Two BSTs Whose Sum is Equal to a Given Value MEDIUM
In this article, we will solve a famous question on the BST: Count pairs from two BSTs whose sum is equal to a given value. It is a famous interview question and has been asked in many interviews.
Pair with given sum in Balanced BST MEDIUM
In this article, we will discuss the problem pair with a given sum in Balanced Binary Search Tree. We will look at examples, algorithms, and implementation of problems.
Pair with given sum in BST MEDIUM
In this article, we will discuss the problem pair with a given sum in Binary Search Tree. We will look at examples, algorithms, and implementation of problems.
K-th smallest element in BST MEDIUM
Binary Search Tree is an extremely useful data structure in practical applications. In this article, we will find the K-th smallest element in the BST.
Floor and Ceil in a Binary Search Tree MEDIUM
In this article, we will briefly learn about binary search tree. We will also discuss how to find the floor and ceil in a binary search tree, in detail using examples.
Two nodes of a BST are swapped, correct the BST MEDIUM
In this article, we will discuss how to correct the BST if two nodes of a BST are swapped, in detail. We will also learn in brief about the binary search tree.
Print leaf nodes from preorder of a BST MEDIUM
In this article, we will learn in brief about binary search trees. We will also discuss how to print the leaf nodes from the preorder of a BST, in detail using examples.
Pairs with a given sum such that Pair Elements lie in different BSTs MEDIUM
In this article, we will discuss the problem pair with a given sum such that pair elements lie in different Binary Search Trees (BSTs). We will look at examples, algorithms, and implementation of problems.
Binary Search Tree Insertion with a Parent Pointer MEDIUM
We will solve the binary search tree insertion problem with a parent pointer using an in-order traversal and insertion approach.
Rank of an Element in a Stream EASY
We will find the rank of an element in a stream by using two approaches. The first is by linear traversal, and the second is by sorting and doing a binary search.
Given N Appointments, find all Conflicting Appointments MEDIUM
This article will discuss a coding problem in which we will be given a list of appointments and we have to find all of the conflicting appointments.
Author Harsh
0 upvotes
Common Nodes in Two Binary Search Trees MEDIUM
In this article, we will discuss a coding problem in which we have to find the common elements between two different Binary Search Trees
Handling duplicates in BST EASY
This article will discuss how to handle duplicates in a Binary search tree and will see its implementation in C++.
Author Harsh
0 upvotes