南京师范大学数据结构课件 第四章.pptVIP

  • 2
  • 0
  • 约3.05千字
  • 约 37页
  • 2019-05-13 发布于广东
  • 举报
内容提要 · 广义表的概念 · 广义表的存储结构 · 广义表的操作算法 广义表的基本操作 构造一个空广义表 销毁广义表 求广义表的长度 求广义表的深度 求广义表的表头 求广义表的表尾 2. 求广义表的深度算法 depth(ls)的递归定义为: 1)递归终止条件: 当ls为空表, depth(ls)=1, 当ls为原子时,depth(ls)=0, 2)递归规律: depth(ls) =1+ Max {depth(ai)} template class T int GList::Depth(GLNode *ls) { if (ls==NULL) return 1; if (ls-tag==0) return 0; max=0, p=ls; while (p); { dep=Depth(p-ptr.hp); if (depmax) max=dep; p=p-ptr.tp; } return max+1; } 3. 取表头算法 template class T GLNode *GList::Head( )

文档评论(0)

1亿VIP精品文档

相关文档