## Transform a BST to greater sum tree

Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node.

Quick Links for Binary Search Tree

Quizzes on BST |

Quizzes on Balanced BST |

Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node.

We have discussed BST search and insert operations. In this post, delete operation is discussed. When we delete a node, there possibilities arise.

The following is definition of Binary Search Tree(BST) according to Wikipedia Binary Search Tree, is a node-based binary tree data structure which has the following… Read More »

Given a Binary Search Tree (BST), modify it so that all greater values in the given BST are added to every node. For example, consider… Read More »

Given two arrays which represent a sequence of keys. Imagine we make a Binary Search Tree (BST) from each array. We need to tell whether… Read More »

Given a Binary Search Tree (BST) and a range [min, max], remove all keys which are outside the given range. The modified tree should also… Read More »

Given a Balanced Binary Search Tree and a target sum, write a function that returns true if there is a pair with sum equals to… Read More »

Given a Balanced Binary Search Tree (BST), write a function isTripletPresent() that returns true if there is a triplet in given BST with sum equals… Read More »

Given a Binary Search Tree (BST), convert it to a Binary Tree such that every key of the original BST is changed to key plus sum of all greater keys in BST

There are numerous applications we need to find floor (ceil) value of a key in a binary search tree or sorted array.

Given preorder traversal of a binary search tree, construct the BST. For example, if the given traversal is {10, 5, 1, 7, 40, 50}, then… Read More »

Two of the nodes of a Binary Search Tree (BST) are swapped. Fix (or correct) the BST.

Given Preorder traversal of a BST, check if each non-leaf node has only one child. Assume that the BST contains unique entries.

Given a Binary Tree, convert it to a Binary Search Tree. The conversion must be done in such a way that keeps the original structure… Read More »