Algorithm_Chapter_5-(精品课件).pptVIP

  • 1
  • 0
  • 约6.03千字
  • 约 29页
  • 2018-10-14 发布于广西
  • 举报
* * * * * * * * * * * * * * * * * * * /deensley/mathdl/Joseph.html /examples/josephusproblem/ /deensley/DiscreteMath/flash/ch1/sec1_1/josephus.html * /JosephusProblem.html /topic/josephus-problem?cat=technology * * * * * /game_nim/nim.html http://www.mathematische-basteleien.de/nimgame.html * Nim Games:/ActivityDetail.aspx?ID=140 Nim:/Nim.html Nim Game:/robban/nim1.htm * * School of Information Science Engineering School of Information Science Engineering 算法分析与设计 Analysis and Design of Computer Algorithms 第五章 减治法 Decrease and Conquer Yunnan University School of Information Science Engineering * 教学内容 减治法的一般方法及变种 插入排序 深度优先查找和广度优先查找 生成组合对象的算法 减常因子算法 减可变规模算法 要求 掌握减治法的基本思想及在常见问题问题中的应用。 Yunnan University School of Information Science Engineering * 减治法 减治技术利用了一种关系:一个问题给定实例的解和同样的问题较小实例的解之间的关系。 一旦建立了这种关系,就可以从顶至下(递归),也可以从底至上(非递归)的来运用。 减治法有三种变种: 1)减去一个常量 2)减去一个常数因子 3)减去的规模是可变的 Yunnan University School of Information Science Engineering * 减(一)治技术 规模为n 的问题 规模为n-1 的子问题 子问题的解 原始问题的解 f(n)=an f(n)=f(n-1)*a n1 f(n)=a n=1 Yunnan University School of Information Science Engineering * 减(半)治技术 规模为n 的问题 规模为n/2 的子问题 子问题的解 原始问题的解 an=(an/2)2 n是偶数 an=(a(n-1)/2)2 *a n是奇数 an =a n=1 Yunnan University School of Information Science Engineering * 插入排序 For j?2 to n do 将A(j)放到已分类集合A(0..j-1)的正确位置上 Repeat 算法 InsertionSort(A[0..n-1]) //用插入排序对给定数组排序 //输入:一个可排序数组 //输出:非降序列数组A for i?1 to n-1 do{ v?A[i]; j?i-1; while (j≥0 and A[j]v){ A[j+1}?A[j]; j?j-1; } A[j+1]?v; } 89 | 45 68 90 29 34 17 45 89 | 68 90 29 34 17 45 68 89 | 90 29 34 17 45 68 89 90 | 29 34 17 29 45 68 89 90 | 34 17 29 34 45 68 89 90 | 17 17 29 34 45 68 89 90 Yunnan University School of Information Science Engineering * 深度优先查找 邻接矩阵表示,该遍历算法的时间效率属于Θ(|V|2) 邻接链表表示,该遍历算法的时间效率属于Θ(|V|+|E|) Yunnan University School of Information Science Engineering * Yunnan University School o

文档评论(0)

1亿VIP精品文档

相关文档