Sunday, October 14, 2012

Binary search tree mirror


BSTreeNode * Mirror_Solution1(BSTreeNode * pRoot)
{

   if(NULL == pRoot)
       return NULL;
   BSTreeNode *p = pRoot->left;
   pRoot->left= pRoot->right;
   pRoot->right = p;
 
   if(NULL != pRoot->left)
       Mirror_Solution1(pRoot->left);
   if(NULL != pRoot->right)
       Mirror_Solution1(pRoot->right);
   
}

No comments:

Post a Comment