[note]Mathematical Analysis of Algorithm(DE Knuth)

Mathematical Analysis of Algorithm (DE Knuth)

主要内容:
    本文开头,写了当时主要存在两种算法复杂度分析, type A 是对某一个具体算法的分析, type
B 是对一个问题某类解决方法的复杂度分析。虽然很多人认为 type B 更重要,但 Knuth 认为 type B
是无法取代 type A 的, type A 也很重要。
    接下来, Knuth 对两个具体的算法进行了分析。
     第一个算法用来解决原位排序的问题。原位排序问题,就是给你两个个一维的数组, x 数组
(x1,x2,...,xn) 和 p 数组,其中 p 数组中的内容是 1 到 n 的一个排列。要求,只能使用 O ( 1 )的额外
空间,也不能改变 p 数组的值,将 x 数组按 (xp(1), xp(2), ..., xp(n)) 排序。
    这个算法,大致上是先找到每个环的 leader ,再对环中的元素进行一次置换,这样这个环中的
数据就都处在了正确的位置。算法的正确性,利用离散数学的相关知识,是比较容易证明的,难点在于
对其复杂度的分析。
    Knuth 借助两个变量 a 和 b 来对复杂度进行分析。首先, a 是从所在环第一个元素到 j 所需进
行的 p(j) 次数, b 是 p 排列中环的个数。最坏情况是容易构造和分析的, Knuth 用了大量的笔墨对平均
情况进行分析。
    首先, Knuth 以特定的规则,将每个 p 排列一一映射成另一个 p 排列。然后将 b 的值与第一类
stirling 数联系起来,由此求到了 b 的平均值以及方差。
    a的平均值求法比较复杂。 Knuth 构造了一个变量 y ,对 a 有了另一种描述 a=sum(yij) 。再
次利用离散数学的知识,求得了 a 的平均值和方差。
     第二个算法相对比较简单,解决的问题是在一个数组中找到第 t 大的数。该算法类似与快排,先
根据一个轴值 k ,将序列分成两个部分,一半比 k 小,一半比 k 大。
    Knuth 用 Cn,t 表示在 n 个元素中找第 t 大所需的比较次数。根据递推式,利用相关数学知识,

最终求到了 Cn,t 的表达式。

收获:
Knuth 的厉害之处除了对数学的灵活运用,还有对模型的构建,他能将问题一步一步转化,将
一开始看起来很难求的 a ,最终求了出来。这里面的技巧值得我们去理解学习。

转载于:https://my.oschina.net/locusxt/blog/205820

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源来自http://b-ok.org/,本人对相关版权等问题不了解,可联系删除 The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1 Donald E. Knuth The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1 Knuth’s multivolume analysis of algorithms is widely recognized as the definitive description of classical computer science. The first three volumes of this work have long comprised a unique and invaluable resource in programming theory and practice. Scientists have marveled at the beauty and elegance of Knuth’s analysis, while practicing programmers have successfully applied his “cookbook” solutions to their day-to-day problems. The level of these first three volumes has remained so high,… —Data Processing Digest Knuth, Volume n has been published, where n = 4A. In this long-awaited new volume, the old master turns his attention to some of his favorite topics in broadword computation and combinatorial generation (exhaustively listing fundamental combinatorial objects, such as permutations, partitions, and trees), as well as his more recent interests, such as binary decision diagrams. The hallmark qualities that distinguish his previous volumes are manifest here anew: detailed coverage of the basics, illustrated with well-chosen examples; occasional forays into more esoteric topics and problems at the frontiers of research; impeccable writing peppered with occasional bits of humor; extensive collections of exercises, all with solutions or helpful hints; a careful attention to history; implementations of many of the algorithms in his classic step-by-step form. There is an amazing amount of information on each page. Knuth has obviously thought long and hard about which topics and results are most central and important, and then, what are the most intuitive and succinct ways of presenting that material. Since the areas that he covers in this volume have exploded since he first envisioned writing about them, it is wonderful how he has ma
资源来自http://b-ok.org/,本人对相关版权等问题不了解,可联系删除 The Art of Computer Programming, Volume 1: Fundamental Algorithms (3rd Edition) Donald E. Knuth This magnificent tour de force presents a comprehensive overview of a wide variety of algorithms and the analysis of them. Now in its third edition, The Art of Computer Programming, Volume I: Fundamental Algorithms contains substantial revisions by the author and includes numerous new exercises. Although this book was conceived several decades ago, it is still a timeless classic. One of the book's greatest strengths is the wonderful collection of problems that accompany each chapter. The author has chosen problems carefully and indexed them according to difficulty. Solving a substantial number of these problems will help you gain a solid understanding of the issues surrounding the given topic. Furthermore, the exercises feature a variety of classic problems. Fundamental Algorithms begins with mathematical preliminaries. The first section offers a good grounding in a variety of useful mathematical tools: proof techniques, combinatorics, and elementary number theory. Knuth then details the MIX processor, a virtual machine architecture that serves as the programming target for subsequent discussions. This wonderful section comprehensively covers the principles of simple machine architecture, beginning with a register-level discussion of the instruction set. A later discussion of a simulator for this machine includes an excellent description of the principles underlying the implementation of subroutines and co-routines. Implementing such a simulator is an excellent introduction to computer design. In the second section, Knuth covers data structures--stacks, queues, lists, arrays, and trees--and presents implementations (in MIX assembly) along with techniques for manipulating these structures. Knuth follows many of the algorithms with careful time and space analysis. In the section on tree structures, the discussion includes a series

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值