Category Archives: Binary Search Tree

Given an array arr, the task is to remove minimum number of elements such that after their removal, max(arr) <= 2 * min(arr). Examples: Input:… Read More
Given an array of integers, find the closest greater element for every element. If there is no greater element then print -1 Examples: Input :… Read More
Given an array of integers, find the closest (not considering distance, but value) greater or same value on left of every element. If an element… Read More
A double ended priority queue supports operations of both max heap (a max priority queue) and min heap (a min priority queue). The following operations… Read More
Given a Binary Search Tree, the task is to find the node with the maximum value in a BST. For the above tree, we start… Read More
Given a Binary Search Tree. The task is to find the sum and product of maximum and minimum value of tree. For the above tree,… Read More
Given an array of integers, the task is to find the sequence in which these integers should be added to an AVL tree such that… Read More
Given the height of an AVL tree ‘h’, the task is to find the minimum number of nodes the tree can have. Examples : Input… Read More
Given a binary search tree. The task is to print all even nodes of the binary search tree. Examples: Input : 5 / \ 3… Read More
Given a Binary Search Tree (BST) and a range [min, max], remove all keys which are inside the given range. The modified tree should also… Read More
Given postorder traversal of a binary search tree, construct the BST. For example, 1. If the given traversal is {1, 7, 5, 50, 40, 10},… Read More
A recursive approach to insert a new node in a BST is already discussed in the post: Binary Search Tree | SET 1. In this… Read More
Given Q queries. The queries are of three types and are described below: Add the number num to the list. Remove the number num from… Read More
Given the root nodes of the two binary search trees. The task is to print 1 if the two Binary Search Trees are identical else… Read More
Given two arrays which represent two sequences of keys that are used to create BSTs. Imagine we make a Binary Search Tree (BST) from each… Read More