您的位置:首页 > 理论基础 > 数据结构算法

广工数据结构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;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: