广工数据结构5.30③ 试按表头、表尾的分析方法重写求广义表 的深度的递归算法。
2014-04-15 00:02
246 查看
int GListDepth(GList ls)
/* Return the depth of list */
{
GList pp;
int max, h, t;
if(!ls)
return 1;
if(ls->tag == ATOM)
return 0;
for(pp=ls; pp; pp=pp->un.ptr.tp){
h = GListDepth(pp->un.ptr.hp)+1;
t = GListDepth(pp->un.ptr.tp);
if(h > t)
return h;
else
return t;
}
}
/* Return the depth of list */
{
GList pp;
int max, h, t;
if(!ls)
return 1;
if(ls->tag == ATOM)
return 0;
for(pp=ls; pp; pp=pp->un.ptr.tp){
h = GListDepth(pp->un.ptr.hp)+1;
t = GListDepth(pp->un.ptr.tp);
if(h > t)
return h;
else
return t;
}
}
相关文章推荐
- 按表头、表尾的分析方法重写求广义表的深度的递归算法
- 重写equals()时为什么也得重写hashCode()之深度解读equals方法与hashCode方法渊源
- Java 深度克隆 clone()方法重写 equals()方法的重写
- 重写equal()时为什么也得重写hashCode()之深度解读equal方法与hashCode方法渊源
- java中方法重载和方法重写分析
- Android 重写ViewGroup 分析onMeasure()和onLayout()方法
- 接口回调;new FileFilter(接口)重写accept递归深度遍历后缀名文件;File[]和stringbuffer两种方法
- 深度学习: 回归分析 评价方法
- 【数据结构java描述(一)】单链表类的create()方法的重写以及Node类的理解
- Java对象的equals方法分析与重写
- 重写equal()时为什么也得重写hashCode()之深度解读equal方法与hashCode方法渊源
- Android App测试分析方法(总结 && 重写)
- 关于java数据结构hashSet与TreeSet重写方法的格式
- 数据结构分析方法
- 分治法及递归算法的分析方法
- 广义表的长度和深度、表头表尾运算
- MFC中重写表头控件替换CListView类的表头类的方法
- [Guava源码分析]Objects 和 ComparisonChain:帮助重写Object方法
- 直接继承View来自定义控件时,需要重写onMeasure()方法并设置wrap_content时的大小 原理分析
- java方法重写实例分析