层次遍历

void  traverse(pBitree root)
{
    queue<pBitree>T;
    T.push(root);
    while (!T.empty())
    {
        printf("%c", T.front()->data);
        if (T.front()->lchild!=NULL)
        T.push(T.front()->lchild);
        if (T.front()->lchild!=NULL)
        T.push(T.front()->rchild);
        T.pop();
    }
}

posted @ 2015-11-14 11:24  式微胡不归  阅读(148)  评论(0编辑  收藏  举报