/*******************************************************************************
/* <FUNC>
/* 函数名   : BSTreeMirror_Recursive
/* 功能     : 二叉查找树递归镜像操作
/* 参数     : -
/* 返回值   : -
/* 备注     : -
/* 作者     : <xxx>
/* </FUNC>
******************************************************************************
*/
void BSTreeMirror_Recursive(BSTreeNode *T)
{
    BSTreeNode 
*exch = NULL;
    
if(T){
        exch 
= T->m_pLeft;  T->m_pRight = T->m_pLeft;  T->m_pLeft = exch;
        BSTreeMirror_Recursive(T
->m_pLeft);
        BSTreeMirror_Recursive(T
->m_pRight);
    }
}

 

 

 

/*******************************************************************************
/* <FUNC>
/* 函数名   : BSTreeMirror_NonRecur
/* 功能     : 二叉查找树非递归镜像操作
/* 参数     : -
/* 返回值   : -
/* 备注     : -
/* 作者     : <xxx>
/* </FUNC>
******************************************************************************
*/
void BSTreeMirror_NonRecur(BSTreeNode *T)
{
    BSTreeNode 
*e;  BSTreeNode *exch;
    LinkQueue Q;  InitQueue(Q);
    EnQueue(Q, T);
    
while (!QueueEmpty(Q)) {
        DeQueue(Q, e);
        
if (e) {
            exch 
= e->m_pRight;  e->m_pRight = e->m_pLeft;  e->m_pLeft = exch;
            EnQueue(Q, e
->m_pLeft);
            EnQueue(Q, e
->m_pRight);
        }
    }
}

 

 

相关文章:

  • 2022-12-23
  • 2022-02-07
  • 2021-11-20
  • 2021-06-12
  • 2021-12-22
  • 2022-02-14
猜你喜欢
  • 2022-02-07
  • 2021-08-23
  • 2022-02-03
  • 2021-11-22
  • 2021-07-03
  • 2022-12-23
相关资源
相似解决方案