# Binary Search Trees

## Binary Search Tree

Binary Search Tree Binary Search Tree is a special type of binary tree that has a specific order of elements in it. Every node in a binary search tree has a unique value. As it is a binary tree, each tree node has maximum of two children. A Binary Search Tree is used to search …

## Trim A Binary Search Tree

Trim a Binary Search Tree Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the result should return the new root of the …

## Range Sum Of BST

Range Sum of BST Link Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. Example 1: Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 Output: 32 Example 2: …

## Convert BST To Greater Tree

Convert BST to Greater Tree Link Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Example: Input: The root of a Binary Search Tree like this: …

## Closest Binary Search Tree Value

Closest Binary Search Tree Value Link Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floating point. You are guaranteed to have only one unique value in the BST that is closest to the target. Example: …

## Lowest Common Ancestor of a Binary Search Tree

Lowest Common Ancestor of a Binary Search Tree Link Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that …

## Minimum Distance Between BST Nodes

Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]