您当前的位置:《数据结构》听课笔记:23
《数据结构》听课笔记:23
数据结构
A :树的逻辑表示
1:双气表示法
2:孩子兄弟表示法
B:树的遍历算法
  1:输出所有从根结点到叶子结点的路径
   算法
   void AllPath(BiTree,Stack &S)
{
  if(T)
    {
     Push(S,T->data)
     if(!T->lchild&&!T->rchild)
     PrintStack(S);
     else
       {
         AllPath(T->lchild,S);
         AllPath(T->rchild,S);
       }
       Pop(S);
  }
 
森林的所有从跟到叶子结点的路径
void OutPath(Bitree T,Stack &S)
{
  while(!T)
  {
    Push(S,T->data)
    if(!T->lchild) PrintStack(S):;
    else OutPath(T->lchild,S);
    Pop(S);
    T=T->rchild;
   }//while
}//OutPath
 
 
收藏状态
收藏本课程的同学
相关课程