/* Inserts the node pointed to by "newNode" into the subtree rooted at "tre
eNode" */
void InsertNode(Node *&treeNode, Node *newNode)
{
if (treeNode == NULL)
treeNode = newNode;
else if (newNode->key < treeNode->key)
InsertNode(treeNode->left, newNode);
else
InsertNode(treeNode->right, newNode);
}
The above "destructive" procedural variant modifies the tree in place. It us
es only constant space, but the previous version of the tree is lost.
我不懂为什么是destructive