Given a BST and a value x, write a function to delete the nodes having values greater than or equal to x. The function will return the modified root
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Basic properties of BST:
Thus it's clear whenever a root has a value greater than or equal to the input value X, the entire right subtree and root need to be deleted, but not the left one.
Algorithm:
The above function actually builds the tree deleting the nodes having greater and equal value than X.
Example with Explanation:
C++ Implementation:
Output