| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3861 人关注过本帖
标题:二叉树的判断
取消只看楼主 加入收藏
jiejiao268
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-4-25
收藏
 问题点数:0 回复次数:0 
二叉树的判断
二叉树怎么判断是否为完全二叉树啊
#include<iostream.h>
#include"BTNode.h"
#include"queue.h"
template<class T>
BTNode<T> * GetBTNode(const T & item,BTNode<T> * lp=NULL,BTNode<T> *rp=NULL)
{
    BTNode<T> *p;
    p=new BTNode<T>(item,lp,rp);
    if(p==NULL)
    {
        cout<<"创建失败"<<endl;
        exit(1);
    }
    return p;
}
template<class T>
void level(const BTNode<T> *t)
{
    if(t==NULL)
        return;
        Queue<const BTNode<T>*>Q;
        Q.Push(t);
        while(!Q.Empty())
        {
            t=Q.Pop();
            cout<<t->data;
            if(t->left)
                Q.Push(t->left);
            if(t->right)
                Q.Push(t->right);
        }
   
}
void main()
{
    BTNode<char> *nullp=NULL;
    BTNode<char> *fp=GetBTNode('F');
    BTNode<char> *dp=GetBTNode('D',fp);
    BTNode<char> *bp=GetBTNode('B',nullp,dp);
    BTNode<char> *ep=GetBTNode('E');
    BTNode<char> *cp=GetBTNode('C',nullp,ep);
    BTNode<char> *ap=GetBTNode('A',bp,cp);
    //level(ap);
    judge(ap);
    cout<<endl;
}
搜索更多相关主题的帖子: include return 二叉树 
2016-04-25 21:22
快速回复:二叉树的判断
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015043 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved