当前位置:网站首页>Traversal of a tree in first order, middle order, and then order

Traversal of a tree in first order, middle order, and then order

2022-07-06 22:35:00 Between the steps

The tree is traversed in order first, in order second ( Recursively defined by binary tree )

The former sequence traversal

void PreOrder(Bitree T){
    
    if(T!=NULL){
    
        visit(T);
        PreOrder(T->Lchild);
        PreOrder(T->Rchild);
        
    }

In the sequence traversal

void PreOrder(Bitree T){
    
    if(T!=NULL){
    
        PreOrder(T->Lchild);
        visit(T);
        PreOrder(T->Rchild);
        
    }

After the sequence traversal

void PreOrder(Bitree T){
    
    if(T!=NULL){
    
        PreOrder(T->Lchild);
        PreOrder(T->Rchild);
        visit(T);
        
    }

Level traversal
 Insert picture description here

原网站

版权声明
本文为[Between the steps]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061455031110.html