22 Problems

Binary Search Trees

Master binary search trees problems with detailed brute force and optimal solutions.

01
Find a value in a BST
Click to view brute force and optimal solutions
02
Deletion of a node in a BST
Click to view brute force and optimal solutions
03
Find min and max value in a BST
Click to view brute force and optimal solutions
04
Find inorder successor and inorder predecessor in a BST
Click to view brute force and optimal solutions
05
Check if a tree is a BST or not
Click to view brute force and optimal solutions
06
Populate Inorder successor of all nodes
Click to view brute force and optimal solutions
07
Find LCA of 2 nodes in a BST
Click to view brute force and optimal solutions
08
Construct BST from preorder traversal
Click to view brute force and optimal solutions
09
Convert Binary tree into BST
Click to view brute force and optimal solutions
10
Convert a normal BST into a Balanced BST
Click to view brute force and optimal solutions
11
Merge two BST [V.V.V.IMP]
Click to view brute force and optimal solutions
IMP
12
Find Kth largest element in a BST
Click to view brute force and optimal solutions
13
Find Kth smallest element in a BST
Click to view brute force and optimal solutions
14
Count pairs from 2 BST whose sum is equal to given value X
Click to view brute force and optimal solutions
15
Find the median of BST in O(n) time and O(1) space
Click to view brute force and optimal solutions
16
Count BST nodes that lie in a given range
Click to view brute force and optimal solutions
17
Replace every element with the least greater element on its right
Click to view brute force and optimal solutions
18
Given n appointments, find the conflicting appointments
Click to view brute force and optimal solutions
19
Check preorder is valid or not
Click to view brute force and optimal solutions
20
Check whether BST contains Dead end
Click to view brute force and optimal solutions
21
Largest BST in a Binary Tree [V.V.V.V.V IMP]
Click to view brute force and optimal solutions
IMP
22
Flatten BST to sorted list
Click to view brute force and optimal solutions