一、深度 递归版本 非递归版本 思想:二叉树的深度就是指二叉树有几层,那么我们可以使用层序遍历来实现。 二、宽度 思想:二叉树的宽度就是最宽的那一层的节点数,所以还是需要层序遍历的思想,先计算每层的结点数,然后找出最大的。 ...
                            
                            
                                分类:
其他好文   时间:
2018-08-16 13:40:09   
                                阅读次数:
114
                             
                    
                        
                            
                            
                                深度:intlength(BiTreet)
{
intdepth1=0;
intdepth2=0;
if(t==null)return0;
//右子树的深度
depth1=length(t.right);
//左子树的深度
depth2=length(t.left);
if(depth1>depth2)
returndepth1+1;
else
returndepth2+1;
}宽度:intgetMaxWidth(TreeNoderoot)
{
if(root==..
                            
                            
                                分类:
其他好文   时间:
2016-08-29 00:18:41   
                                阅读次数:
182
                             
                    
                        
                            
                            
                                题目题目标题:求二叉树的宽度和深度
给定一个二叉树,获取该二叉树的宽度和深度。   例如输入
   a
  /  b   c
/ \ / d e f g返回3.
接口说明 
原型:     int GetBiNodeInfo(BiNode &head, unsigned int *pulWidth, unsigned int *pulHeight)
输入参数:     head   需要获取...
                            
                            
                                分类:
其他好文   时间:
2015-07-03 15:48:28   
                                阅读次数:
150
                             
                    
                        
                            
                            
                                求二叉树的宽度和深度
给定一个二叉树,获取该二叉树的宽度和深度。...
                            
                            
                                分类:
其他好文   时间:
2014-05-11 20:43:19   
                                阅读次数:
571