写出TREE-MINIMUM 和TREE-MAXIMUM的递归版本(算法导论第三版12.2-2)
template<typename T>
BinaryTreeNode<T>* tree_minimum_recursion(BinaryTreeNode<T>* node)
{if(node == nullptr) return node;if(node->left != nullptr)return tree_minimum_recursion(node->left);elsereturn node;
}
template<typename T>
BinaryTreeNode<T>* tree_maximum_recursion(BinaryTreeNode<T> *node)
{if(node == nullptr) return node;if(node->right!= nullptr)return tree_maximum_recursion(node->right);else return node;
}
辅助类
BinaryTreeNode地址