so I have this code for inserting a node in a binary tree what I didn't understand is the use of double pointers, why doesn't work with regular pointers
ptr = tree root
mData = the variable that stores the data
mLeftPtr,mRightPtr = pointers of treenode objects which point to other treenode objects
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
template<typename NODETYPE>
void Tree<NODETYPE>::insertNodeHelper(TreeNode<NODETYPE>** ptr, const NODETYPE value)
{
if (*ptr == NULL)
*ptr = new TreeNode<NODETYPE>(value);
else
{
if (value < (*ptr)->mData)
insertNodeHelper(&((*ptr)->mLeftPtr), value);
else
{
if (value > (*ptr)->mData)
insertNodeHelper(&((*ptr)->mRightPtr), value);
}
}
}