Hierarchical data structure with efficient search, insertion, and deletion operations.
Problem Statement: Given a root of Binary Tree, where the nodes have integer values. Return the size of the largest subtree of the binary tree which is also a BST. A binary search tree (BST) is a b...
Problem Statement: Given the root of a Binary Search Tree (BST), where the values of exactly two nodes of the BST have been swapped. Recover the tree without changing its structure. Examples Input:...
Problem Statement: Given the root of a Binary Search Tree and an integer k, return true if there exist two elements in the BST such that their sum is equal to k, or false otherwise. Examples Input:...
Problem Statement: Given a Binary Search Tree and a ‘key’ value which represents the data data of a node in this tree. Return the inorder predecessor and successor of the given node in the BST....
Problem Statement: Given a preorder traversal of a binary search tree. Return the root of the Binary Search Tree constructed from the given preorder array. Examples Example 1: Input:Input Array: [...
Problem Statement: Given the root node of a binary search tree (BST) and two node values p and q, return the lowest common ancestors(LCA) of the two nodes in BST. Examples Input: root = [5, 3, 6, 2...
Problem Statement: Given the root node of a binary tree, return true if the given binary tree is a binary search tree (BST) else false. A valid BST is defined as follows: The left subtree of a node...
Problem Statement: Given the root node of a binary search tree (BST) and a value val to insert into the tree. Return the root node of the BST after the insertion. It is guaranteed that the new valu...
Problem Statement: Given the root node of a binary search tree (BST) and a value key. Return the root node of the BST after the deletion of the node with the given key value. Note: As there can be...
Problem Statement: Given a Binary Search Tree and a key, return the floor of the given key in the Binary Search Tree. Floor of a value refers to the value of the largest node in the Binary Search T...