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 Binary Search Tree

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 Trim A Binary Search Tree

Range Sum Of BST | LeetCode

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: Range Sum Of BST | LeetCode

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: Convert BST To Greater Tree

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: Closest Binary Search Tree Value

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 Lowest Common Ancestor of a Binary Search Tree

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.

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