January 09, 2025 |7.7K Views

    Remove BST keys outside the given range

      Share   Like
    Description
    Discussion


    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 be BST. For example, consider the following BST and range [-10, 13]. 
    There are two possible cases for every node.

    Node’s key is outside the given range. This case has two sub-cases. 
    Node’s key is smaller than the min value. 
    Node’s key is greater than the max value.

    Remove BST keys outside the given range  : https://www.geeksforgeeks.org/remove-bst-keys-outside-the-given-range/