下载此文档

信息与计算科学专业毕业论文--算法设计中的递归与非递归转换.doc


文档分类:IT计算机 | 页数:约16页 举报非法文档有奖
1/16
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/16 下载此文档
文档列表 文档介绍
摘要
算法设计中的递归和非递归转换是学习算法设计的基础,熟练地运用递归与非递归转换是算法设计的基础,。
关键词:算法设计递归与非递归转换

Abstract
The algorithm design recursive and non recursive conversion is the basis for learning algorithm design, skilled use of recursive and non recursive conversion is the basis for algorithm design in this paper I will introduce several algorithm design recursive and non recursive conversion method. so that we can better achieve the recursive algorithm design and non-recursive conversion.
Keywords: algorithm design recursive and non recursive conversion
三种遍历树的算法
     递归与非递归转换的基础知识是能够正确理解三种树的遍历方法:前序,中序和后序,第一篇就是关于这三种遍历方法的递归和非递归算法。
一、为什么要学习递归与非递归的转换的实现方法
     .
     .
     ,树等数据结构.
二、三种遍历树的递归和非递归算法
     递归与非递归的转换基于以下的原理:,这个"原理"并没有经过严格的数学证明,只是我的一个猜想,,有三种方法可以遍历树:前序,中序,,,这里以特殊的二叉树来说明,不过大多数情况下二叉树已经够用,而且理解了二叉树的遍历,其它的树遍历方式就不难了。
         1)前序遍历
         a)递归方式:
               void preorder_recursive(Bitree T)      /* 先序遍历二叉树的递归算法*/
                     {
                        if (T) {
                           visit(T);          /* 访问当前结点*/
                           preorder_recursive(T->lchild);   /* 访问左子树*/
                           preorder_recursive(T->rchild);   /* 访问右子树*/
                        }
                     }
         b)非递归方式
               void preorder_nonrecursive(Bitree T)      /* 先序遍历二叉树的非递归算法*/
                     {
                        initstack(S);
                        push(S,T);             /* 根指针进栈*/
                        while(!stackempty(S)) {
                           while(gettop(S,p)&&p) {      /* 向左走到尽头*/
                              visit(p);      /* 每向前走一步都访问当前结点*/
                              push(S,p->lchild);
                           }
                           pop(S,p);
                           if(!stackempty(S))

信息与计算科学专业毕业论文--算法设计中的递归与非递归转换 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数16
  • 收藏数0 收藏
  • 顶次数0
  • 上传人小马康康
  • 文件大小60 KB
  • 时间2018-05-01
最近更新