Skip to content

Category Archives: Binary Search Tree

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, If the given traversal is {1, 7, 5, 50, 40, 10}, then following tree… Read More
You are given a binary search tree (BST) and a value to insert into the tree. Print inorder traversal of the BST after the insertion.Example:… 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 “Both BSTs are identical” if the two Binary Search Trees… 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
Given a BST and a number. The task is to check whether the given number is equal to the sum of all the node from… Read More
Given a BST and a key Node, find the total sum in BST, except those Node which are adjacent to key Node.  Examples: Recommended: Please… Read More
Given a preorder traversal of a BST. The task is to find the number of elements less than root.  Examples:  Input: preorder[] = {3, 2,… Read More
Consider a problem where same elements are likely to be searched again and again. Implement search operation efficiently.  Examples :  Input : arr[] = {12… Read More
Given an array of positive and negative integers and an integer K. The task is to find the subarray which has its sum closest to… Read More
3Given an array of distinct elements, print the closest greater element for every element. The closest greater element for an element x is the smallest… Read More
Given a Binary Search Tree and a number x, find the floor of x in the given BST: Examples: Input: x = 14 and root… Read More
Online Round: This round was held on Hackerrank for 1:30 hrs. There were two questions in this round. A tree was given with upto 10^5 nodes.… Read More