//--------------------------- Delete a Node ------------------------------------------------
// This function deletes the Node with 'value' as it's key. This is to be called inside removeRange() function
// SILVER TODO Complete the implementation of this function
Node* BST::deleteNode(Node *currNode, int value)
{
if(currNode == NULL)
{
returnNULL;
}
elseif(value < currnode-="">key)
{
currNode->left = deleteNode(currNode->left, value);
}
elseif(value > currNode->key)
{
currNode->right = deleteNode(currNode->right, value);
}
// We found the node with the value
else
{
//TODO Case : No child
if(currNode->left == NULL && currNode->right == NULL)
{
}
//TODO Case : Only right child
elseif(currNode->left == NULL)
{
}
//TODO Case : Only left child
elseif(currNode->right == NULL)
{
}
//TODO Case: Both left and right child
else
{
///Replace with Minimum from right subtree
}
}
return currNode;
}
// This function removes nodes with values in the range low and high.
// You need to call deleteNode() function inside this function
void BST::removeRange(int low, int high)
{
for(inti=low; i<=high;>=high;>
root=deleteNode(root,i);
}
}