Delete Node in BST
Concepts and Basic Operations DSA practice problem on Onlearn.
Difficulty: medium.
Topics: Delete a Node in Binary Search Tree, Binary Search Tree, Node, Recursion, Binary Tree, Time Complexity, Space Complexity, tree traversal, tree operations, recursion, binary search tree, Insertion & Deletion in BST.
Problem Statement Given the root of a Binary Search Tree (BST) and an integer key, delete the node with the given key from the BST. Return the root of the BST after deletion. If the key is not found in the BST, the tree should remain unchanged. It is guaranteed that the key will be unique if it exists in the BST. Input Specification The input will consist of: The root of a Binary Search Tree. Each node will have an integer value, a left child pointer, and a right child pointer. An integer key representing the value of the node to be deleted. Output Specification Return the root of the modified Binary Search Tree after the deletion operation. Constraints The number of nodes in the BST will be in the range [0, 10^4]. Node values will be in the range [ 10^5, 10^5]. key will be in the range [ 10^5, 10^5]. It is guaranteed that the node values are unique.