January 10, 2025 |5.7K Views

    Print BST keys in the given range

      Share  1 Like
    Description
    Discussion

    Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Print all the keys of the tree in range k1 to k2. i.e. print all x such that k1<=x<=k2 and x is a key of given BST. Print all the keys in increasing order. 
    Example:

    Graph:


    Input: k1 = 10 and k2 = 22


    Output: 12, 20 and 22.


    Explanation: The keys are 4, 8, 12, 20, and 22.
    So keys in range 10 to 22 is 12, 20 and 22.

    Print BST keys in the given range: https://www.geeksforgeeks.org/print-bst-keys-in-the-given-range/